Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: chrome/browser/extensions/extension_idle_api.cc

Issue 10696208: Move ExtensionEventRouter and related into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed bug + latest master Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/extension_idle_api.h" 5 #include "chrome/browser/extensions/extension_idle_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "chrome/browser/extensions/extension_event_router.h" 17 #include "chrome/browser/extensions/event_router.h"
18 #include "chrome/browser/extensions/extension_host.h" 18 #include "chrome/browser/extensions/extension_host.h"
19 #include "chrome/browser/extensions/extension_idle_api_constants.h" 19 #include "chrome/browser/extensions/extension_idle_api_constants.h"
20 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/common/extensions/extension.h" 22 #include "chrome/common/extensions/extension.h"
23 #include "content/public/browser/render_view_host.h" 23 #include "content/public/browser/render_view_host.h"
24 24
25 namespace keys = extension_idle_api_constants; 25 namespace keys = extension_idle_api_constants;
26 26
27 namespace { 27 namespace {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 void ExtensionIdleEventRouter::OnIdleStateChange(Profile* profile, 139 void ExtensionIdleEventRouter::OnIdleStateChange(Profile* profile,
140 IdleState state) { 140 IdleState state) {
141 // Prepare the single argument of the current state. 141 // Prepare the single argument of the current state.
142 ListValue args; 142 ListValue args;
143 args.Append(CreateIdleValue(state)); 143 args.Append(CreateIdleValue(state));
144 std::string json_args; 144 std::string json_args;
145 base::JSONWriter::Write(&args, &json_args); 145 base::JSONWriter::Write(&args, &json_args);
146 146
147 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 147 profile->GetExtensionEventRouter()->DispatchEventToRenderers(
148 keys::kOnStateChanged, json_args, profile, GURL(), EventFilteringInfo()); 148 keys::kOnStateChanged, json_args, profile,
149 GURL(), extensions::EventFilteringInfo());
149 } 150 }
150 151
151 bool ExtensionIdleQueryStateFunction::RunImpl() { 152 bool ExtensionIdleQueryStateFunction::RunImpl() {
152 int threshold; 153 int threshold;
153 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &threshold)); 154 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &threshold));
154 threshold = CheckThresholdBounds(threshold); 155 threshold = CheckThresholdBounds(threshold);
155 156
156 IdleState state = ExtensionIdleCache::CalculateIdleState(threshold); 157 IdleState state = ExtensionIdleCache::CalculateIdleState(threshold);
157 if (state != IDLE_STATE_UNKNOWN) { 158 if (state != IDLE_STATE_UNKNOWN) {
158 SetResult(CreateIdleValue(state)); 159 SetResult(CreateIdleValue(state));
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 } 263 }
263 } 264 }
264 265
265 int ExtensionIdleCache::get_min_threshold() { 266 int ExtensionIdleCache::get_min_threshold() {
266 return kMinThreshold; 267 return kMinThreshold;
267 } 268 }
268 269
269 double ExtensionIdleCache::get_throttle_interval() { 270 double ExtensionIdleCache::get_throttle_interval() {
270 return static_cast<double>(kThrottleInterval); 271 return static_cast<double>(kThrottleInterval);
271 } 272 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_host.cc ('k') | chrome/browser/extensions/extension_input_ime_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698