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

Side by Side Diff: chrome/browser/extensions/api/location/location_api.cc

Issue 252653002: Rename (Chrome)SyncExtensionFunction::RunImpl to RunSync so that the RunImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bookmarks Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/location/location_api.h" 5 #include "chrome/browser/extensions/api/location/location_api.h"
6 6
7 #include "chrome/browser/extensions/api/location/location_manager.h" 7 #include "chrome/browser/extensions/api/location/location_manager.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/common/extensions/api/location.h" 9 #include "chrome/common/extensions/api/location.h"
10 #include "extensions/common/error_utils.h" 10 #include "extensions/common/error_utils.h"
11 11
12 // TODO(vadimt): add tests. 12 // TODO(vadimt): add tests.
13 13
14 namespace location = extensions::api::location; 14 namespace location = extensions::api::location;
15 namespace WatchLocation = location::WatchLocation; 15 namespace WatchLocation = location::WatchLocation;
16 namespace ClearWatch = location::ClearWatch; 16 namespace ClearWatch = location::ClearWatch;
17 17
18 namespace extensions { 18 namespace extensions {
19 19
20 const char kMustBePositive[] = "'*' must be 0 or greater."; 20 const char kMustBePositive[] = "'*' must be 0 or greater.";
21 const char kMinDistanceInMeters[] = "minDistanceInMeters"; 21 const char kMinDistanceInMeters[] = "minDistanceInMeters";
22 const char kMinTimeInMilliseconds[] = "minTimeInMilliseconds"; 22 const char kMinTimeInMilliseconds[] = "minTimeInMilliseconds";
23 23
24 bool IsNegative(double* value) { 24 bool IsNegative(double* value) {
25 return value && *value < 0.0; 25 return value && *value < 0.0;
26 } 26 }
27 27
28 bool LocationWatchLocationFunction::RunImpl() { 28 bool LocationWatchLocationFunction::RunSync() {
29 scoped_ptr<WatchLocation::Params> params( 29 scoped_ptr<WatchLocation::Params> params(
30 WatchLocation::Params::Create(*args_)); 30 WatchLocation::Params::Create(*args_));
31 EXTENSION_FUNCTION_VALIDATE(params.get()); 31 EXTENSION_FUNCTION_VALIDATE(params.get());
32 32
33 double* min_distance_in_meters = 33 double* min_distance_in_meters =
34 params->request_info.min_distance_in_meters.get(); 34 params->request_info.min_distance_in_meters.get();
35 if (IsNegative(min_distance_in_meters)) { 35 if (IsNegative(min_distance_in_meters)) {
36 error_ = ErrorUtils::FormatErrorMessage( 36 error_ = ErrorUtils::FormatErrorMessage(
37 kMustBePositive, 37 kMustBePositive,
38 kMinDistanceInMeters); 38 kMinDistanceInMeters);
(...skipping 12 matching lines...) Expand all
51 // TODO(vadimt): validate and use params->request_info.maximumAge 51 // TODO(vadimt): validate and use params->request_info.maximumAge
52 LocationManager::Get(GetProfile()) 52 LocationManager::Get(GetProfile())
53 ->AddLocationRequest(extension_id(), 53 ->AddLocationRequest(extension_id(),
54 params->name, 54 params->name,
55 min_distance_in_meters, 55 min_distance_in_meters,
56 min_time_in_milliseconds); 56 min_time_in_milliseconds);
57 57
58 return true; 58 return true;
59 } 59 }
60 60
61 bool LocationClearWatchFunction::RunImpl() { 61 bool LocationClearWatchFunction::RunSync() {
62 scoped_ptr<ClearWatch::Params> params( 62 scoped_ptr<ClearWatch::Params> params(
63 ClearWatch::Params::Create(*args_)); 63 ClearWatch::Params::Create(*args_));
64 EXTENSION_FUNCTION_VALIDATE(params.get()); 64 EXTENSION_FUNCTION_VALIDATE(params.get());
65 65
66 LocationManager::Get(GetProfile()) 66 LocationManager::Get(GetProfile())
67 ->RemoveLocationRequest(extension_id(), params->name); 67 ->RemoveLocationRequest(extension_id(), params->name);
68 68
69 return true; 69 return true;
70 } 70 }
71 71
72 } // namespace extensions 72 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/location/location_api.h ('k') | chrome/browser/extensions/api/log_private/log_private_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698