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

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

Issue 171813010: Move ProfileKeyedAPI implementations to take BrowserContext in the constructor (part 1). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: browser_context_ Created 6 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_ALARM_MANAGER_H__ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARM_MANAGER_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARM_MANAGER_H__ 6 #define CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARM_MANAGER_H__
7 7
8 #include <map> 8 #include <map>
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
16 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" 16 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
17 #include "chrome/common/extensions/api/alarms.h" 17 #include "chrome/common/extensions/api/alarms.h"
18 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
20 #include "extensions/browser/extension_function.h" 20 #include "extensions/browser/extension_function.h"
21 21
22 class Profile; 22 class Profile;
23 23
24 namespace base { 24 namespace base {
25 class Clock; 25 class Clock;
26 } // namespace base 26 } // namespace base
27 27
28 namespace content {
29 class BrowserContext;
30 } // namespace content
31
28 namespace extensions { 32 namespace extensions {
29 33
30 class ExtensionAlarmsSchedulingTest; 34 class ExtensionAlarmsSchedulingTest;
31 35
32 struct Alarm { 36 struct Alarm {
33 Alarm(); 37 Alarm();
34 Alarm(const std::string& name, 38 Alarm(const std::string& name,
35 const api::alarms::AlarmCreateInfo& create_info, 39 const api::alarms::AlarmCreateInfo& create_info,
36 base::TimeDelta min_granularity, 40 base::TimeDelta min_granularity,
37 base::Time now); 41 base::Time now);
(...skipping 21 matching lines...) Expand all
59 typedef std::vector<Alarm> AlarmList; 63 typedef std::vector<Alarm> AlarmList;
60 64
61 class Delegate { 65 class Delegate {
62 public: 66 public:
63 virtual ~Delegate() {} 67 virtual ~Delegate() {}
64 // Called when an alarm fires. 68 // Called when an alarm fires.
65 virtual void OnAlarm(const std::string& extension_id, 69 virtual void OnAlarm(const std::string& extension_id,
66 const Alarm& alarm) = 0; 70 const Alarm& alarm) = 0;
67 }; 71 };
68 72
69 explicit AlarmManager(Profile* profile); 73 explicit AlarmManager(content::BrowserContext* context);
70 virtual ~AlarmManager(); 74 virtual ~AlarmManager();
71 75
72 // Override the default delegate. Callee assumes onwership. Used for testing. 76 // Override the default delegate. Callee assumes onwership. Used for testing.
73 void set_delegate(Delegate* delegate) { delegate_.reset(delegate); } 77 void set_delegate(Delegate* delegate) { delegate_.reset(delegate); }
74 78
75 typedef base::Callback<void()> AddAlarmCallback; 79 typedef base::Callback<void()> AddAlarmCallback;
76 // Adds |alarm| for the given extension, and starts the timer. Invokes 80 // Adds |alarm| for the given extension, and starts the timer. Invokes
77 // |callback| when done. 81 // |callback| when done.
78 void AddAlarm(const std::string& extension_id, 82 void AddAlarm(const std::string& extension_id,
79 const Alarm& alarm, 83 const Alarm& alarm,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 236
233 // Next poll's time. 237 // Next poll's time.
234 base::Time next_poll_time_; 238 base::Time next_poll_time_;
235 239
236 DISALLOW_COPY_AND_ASSIGN(AlarmManager); 240 DISALLOW_COPY_AND_ASSIGN(AlarmManager);
237 }; 241 };
238 242
239 } // namespace extensions 243 } // namespace extensions
240 244
241 #endif // CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARM_MANAGER_H__ 245 #endif // CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARM_MANAGER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698