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/api/idle/idle_api.h" | 5 #include "chrome/browser/extensions/api/idle/idle_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "chrome/browser/extensions/api/idle/idle_api_constants.h" | 9 #include "chrome/browser/extensions/api/idle/idle_api_constants.h" |
10 #include "chrome/browser/extensions/api/idle/idle_manager.h" | 10 #include "chrome/browser/extensions/api/idle/idle_manager.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 threshold = kMaxThreshold; | 23 threshold = kMaxThreshold; |
24 } | 24 } |
25 | 25 |
26 return threshold; | 26 return threshold; |
27 } | 27 } |
28 | 28 |
29 } // namespace | 29 } // namespace |
30 | 30 |
31 namespace extensions { | 31 namespace extensions { |
32 | 32 |
33 bool IdleQueryStateFunction::RunImpl() { | 33 bool IdleQueryStateFunction::RunAsync() { |
34 int threshold; | 34 int threshold; |
35 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &threshold)); | 35 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &threshold)); |
36 threshold = ClampThreshold(threshold); | 36 threshold = ClampThreshold(threshold); |
37 | 37 |
38 IdleManagerFactory::GetForProfile(GetProfile())->QueryState( | 38 IdleManagerFactory::GetForProfile(GetProfile())->QueryState( |
39 threshold, base::Bind(&IdleQueryStateFunction::IdleStateCallback, this)); | 39 threshold, base::Bind(&IdleQueryStateFunction::IdleStateCallback, this)); |
40 | 40 |
41 // Don't send the response, it'll be sent by our callback | 41 // Don't send the response, it'll be sent by our callback |
42 return true; | 42 return true; |
43 } | 43 } |
44 | 44 |
45 void IdleQueryStateFunction::IdleStateCallback(IdleState state) { | 45 void IdleQueryStateFunction::IdleStateCallback(IdleState state) { |
46 SetResult(IdleManager::CreateIdleValue(state)); | 46 SetResult(IdleManager::CreateIdleValue(state)); |
47 SendResponse(true); | 47 SendResponse(true); |
48 } | 48 } |
49 | 49 |
50 bool IdleSetDetectionIntervalFunction::RunSync() { | 50 bool IdleSetDetectionIntervalFunction::RunSync() { |
51 int threshold; | 51 int threshold; |
52 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &threshold)); | 52 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &threshold)); |
53 threshold = ClampThreshold(threshold); | 53 threshold = ClampThreshold(threshold); |
54 | 54 |
55 IdleManagerFactory::GetForProfile(GetProfile()) | 55 IdleManagerFactory::GetForProfile(GetProfile()) |
56 ->SetThreshold(extension_id(), threshold); | 56 ->SetThreshold(extension_id(), threshold); |
57 | 57 |
58 return true; | 58 return true; |
59 } | 59 } |
60 | 60 |
61 } // namespace extensions | 61 } // namespace extensions |
OLD | NEW |