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

Side by Side Diff: chrome/browser/extensions/api/alarms/alarms_api.h

Issue 12314056: Make chrome/browser/extensions use base::Clock instead of MockTimeProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add include Created 7 years, 10 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) 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARMS_API_H__ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARMS_API_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARMS_API_H__ 6 #define CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARMS_API_H__
7 7
8 #include "chrome/browser/extensions/extension_function.h" 8 #include "chrome/browser/extensions/extension_function.h"
9 9
10 namespace base {
11 class Clock;
12 } // namespace base
13
10 namespace extensions { 14 namespace extensions {
11 15
12 class AlarmsCreateFunction : public SyncExtensionFunction { 16 class AlarmsCreateFunction : public SyncExtensionFunction {
13 typedef base::Time (*TimeProvider)();
14 public: 17 public:
15 AlarmsCreateFunction(); 18 AlarmsCreateFunction();
16 explicit AlarmsCreateFunction(TimeProvider now) : now_(now) {} 19 // Use |clock| instead of the default clock. Does not take ownership
20 // of |clock|. Used for testing.
21 explicit AlarmsCreateFunction(base::Clock* clock);
17 protected: 22 protected:
18 virtual ~AlarmsCreateFunction() {} 23 virtual ~AlarmsCreateFunction();
19 24
20 // ExtensionFunction: 25 // ExtensionFunction:
21 virtual bool RunImpl() OVERRIDE; 26 virtual bool RunImpl() OVERRIDE;
22 DECLARE_EXTENSION_FUNCTION("alarms.create", ALARMS_CREATE) 27 DECLARE_EXTENSION_FUNCTION("alarms.create", ALARMS_CREATE)
23 private: 28 private:
24 TimeProvider now_; 29 base::Clock* const clock_;
30 // Whether or not we own |clock_|. This is needed because we own it
31 // when we create it ourselves, but not when it's passed in for
32 // testing.
33 bool owns_clock_;
25 }; 34 };
26 35
27 class AlarmsGetFunction : public SyncExtensionFunction { 36 class AlarmsGetFunction : public SyncExtensionFunction {
28 protected: 37 protected:
29 virtual ~AlarmsGetFunction() {} 38 virtual ~AlarmsGetFunction() {}
30 39
31 // ExtensionFunction: 40 // ExtensionFunction:
32 virtual bool RunImpl() OVERRIDE; 41 virtual bool RunImpl() OVERRIDE;
33 DECLARE_EXTENSION_FUNCTION("alarms.get", ALARMS_GET) 42 DECLARE_EXTENSION_FUNCTION("alarms.get", ALARMS_GET)
34 }; 43 };
(...skipping 21 matching lines...) Expand all
56 virtual ~AlarmsClearAllFunction() {} 65 virtual ~AlarmsClearAllFunction() {}
57 66
58 // ExtensionFunction: 67 // ExtensionFunction:
59 virtual bool RunImpl() OVERRIDE; 68 virtual bool RunImpl() OVERRIDE;
60 DECLARE_EXTENSION_FUNCTION("alarms.clearAll", ALARMS_CLEARALL) 69 DECLARE_EXTENSION_FUNCTION("alarms.clearAll", ALARMS_CLEARALL)
61 }; 70 };
62 71
63 } // namespace extensions 72 } // namespace extensions
64 73
65 #endif // CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARMS_API_H__ 74 #endif // CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARMS_API_H__
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/alarms/alarm_manager.cc ('k') | chrome/browser/extensions/api/alarms/alarms_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698