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 22 matching lines...) Expand all Loading... |
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) { |
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 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( | 44 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( |
44 extension_id, kOnAlarmEvent, args.Pass(), NULL, GURL()); | 45 extension_id, event.Pass()); |
45 } | 46 } |
46 | 47 |
47 private: | 48 private: |
48 Profile* profile_; | 49 Profile* profile_; |
49 }; | 50 }; |
50 | 51 |
51 // Creates a TimeDelta from a delay as specified in the API. | 52 // Creates a TimeDelta from a delay as specified in the API. |
52 base::TimeDelta TimeDeltaFromDelay(double delay_in_minutes) { | 53 base::TimeDelta TimeDeltaFromDelay(double delay_in_minutes) { |
53 return base::TimeDelta::FromMicroseconds( | 54 return base::TimeDelta::FromMicroseconds( |
54 delay_in_minutes * base::Time::kMicrosecondsPerMinute); | 55 delay_in_minutes * base::Time::kMicrosecondsPerMinute); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 if (create_info.period_in_minutes.get()) { | 377 if (create_info.period_in_minutes.get()) { |
377 js_alarm->period_in_minutes.reset( | 378 js_alarm->period_in_minutes.reset( |
378 new double(*create_info.period_in_minutes)); | 379 new double(*create_info.period_in_minutes)); |
379 } | 380 } |
380 } | 381 } |
381 | 382 |
382 Alarm::~Alarm() { | 383 Alarm::~Alarm() { |
383 } | 384 } |
384 | 385 |
385 } // namespace extensions | 386 } // namespace extensions |
OLD | NEW |