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/alarms/alarm_manager.h" | 5 #include "chrome/browser/extensions/api/alarms/alarm_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 // The minimum period between polling for alarms to run. | 31 // The minimum period between polling for alarms to run. |
32 const base::TimeDelta kDefaultMinPollPeriod = base::TimeDelta::FromDays(1); | 32 const base::TimeDelta kDefaultMinPollPeriod = base::TimeDelta::FromDays(1); |
33 | 33 |
34 class DefaultAlarmDelegate : public AlarmManager::Delegate { | 34 class DefaultAlarmDelegate : public AlarmManager::Delegate { |
35 public: | 35 public: |
36 explicit DefaultAlarmDelegate(Profile* profile) : profile_(profile) {} | 36 explicit DefaultAlarmDelegate(Profile* profile) : profile_(profile) {} |
37 virtual ~DefaultAlarmDelegate() {} | 37 virtual ~DefaultAlarmDelegate() {} |
38 | 38 |
39 virtual void OnAlarm(const std::string& extension_id, | 39 virtual void OnAlarm(const std::string& extension_id, |
40 const Alarm& alarm) { | 40 const Alarm& alarm) OVERRIDE { |
41 scoped_ptr<ListValue> args(new ListValue()); | 41 scoped_ptr<ListValue> args(new ListValue()); |
42 args->Append(alarm.js_alarm->ToValue().release()); | 42 args->Append(alarm.js_alarm->ToValue().release()); |
43 scoped_ptr<Event> event(new Event(kOnAlarmEvent, args.Pass())); | 43 scoped_ptr<Event> event(new Event(kOnAlarmEvent, args.Pass())); |
44 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( | 44 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( |
45 extension_id, event.Pass()); | 45 extension_id, event.Pass()); |
46 } | 46 } |
47 | 47 |
48 private: | 48 private: |
49 Profile* profile_; | 49 Profile* profile_; |
50 }; | 50 }; |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 if (create_info.period_in_minutes.get()) { | 368 if (create_info.period_in_minutes.get()) { |
369 js_alarm->period_in_minutes.reset( | 369 js_alarm->period_in_minutes.reset( |
370 new double(*create_info.period_in_minutes)); | 370 new double(*create_info.period_in_minutes)); |
371 } | 371 } |
372 } | 372 } |
373 | 373 |
374 Alarm::~Alarm() { | 374 Alarm::~Alarm() { |
375 } | 375 } |
376 | 376 |
377 } // namespace extensions | 377 } // namespace extensions |
OLD | NEW |