| OLD | NEW |
| 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 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // Don't send the response, it'll be sent by our callback | 168 // Don't send the response, it'll be sent by our callback |
| 169 return true; | 169 return true; |
| 170 } | 170 } |
| 171 | 171 |
| 172 void ExtensionIdleEventRouter::OnIdleStateChange(Profile* profile, | 172 void ExtensionIdleEventRouter::OnIdleStateChange(Profile* profile, |
| 173 IdleState state) { | 173 IdleState state) { |
| 174 // Prepare the single argument of the current state. | 174 // Prepare the single argument of the current state. |
| 175 ListValue args; | 175 ListValue args; |
| 176 args.Append(CreateIdleValue(state)); | 176 args.Append(CreateIdleValue(state)); |
| 177 std::string json_args; | 177 std::string json_args; |
| 178 base::JSONWriter::Write(&args, false, &json_args); | 178 base::JSONWriter::Write(&args, &json_args); |
| 179 | 179 |
| 180 profile->GetExtensionEventRouter()->DispatchEventToRenderers( | 180 profile->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 181 keys::kOnStateChanged, json_args, profile, GURL()); | 181 keys::kOnStateChanged, json_args, profile, GURL()); |
| 182 } | 182 } |
| 183 | 183 |
| 184 ExtensionIdleCache::CacheData ExtensionIdleCache::cached_data = | 184 ExtensionIdleCache::CacheData ExtensionIdleCache::cached_data = |
| 185 {-1, -1, -1, -1}; | 185 {-1, -1, -1, -1}; |
| 186 | 186 |
| 187 IdleState ExtensionIdleCache::CalculateIdleState(int threshold) { | 187 IdleState ExtensionIdleCache::CalculateIdleState(int threshold) { |
| 188 return CalculateState(threshold, base::Time::Now().ToDoubleT()); | 188 return CalculateState(threshold, base::Time::Now().ToDoubleT()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } | 261 } |
| 262 } | 262 } |
| 263 | 263 |
| 264 int ExtensionIdleCache::get_min_threshold() { | 264 int ExtensionIdleCache::get_min_threshold() { |
| 265 return kMinThreshold; | 265 return kMinThreshold; |
| 266 } | 266 } |
| 267 | 267 |
| 268 double ExtensionIdleCache::get_throttle_interval() { | 268 double ExtensionIdleCache::get_throttle_interval() { |
| 269 return static_cast<double>(kThrottleInterval); | 269 return static_cast<double>(kThrottleInterval); |
| 270 } | 270 } |
| OLD | NEW |