| 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/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 return base::TimeDelta::FromDays(1); | 35 return base::TimeDelta::FromDays(1); |
| 36 } | 36 } |
| 37 | 37 |
| 38 class DefaultAlarmDelegate : public AlarmManager::Delegate { | 38 class DefaultAlarmDelegate : public AlarmManager::Delegate { |
| 39 public: | 39 public: |
| 40 explicit DefaultAlarmDelegate(content::BrowserContext* context) | 40 explicit DefaultAlarmDelegate(content::BrowserContext* context) |
| 41 : browser_context_(context) {} | 41 : browser_context_(context) {} |
| 42 virtual ~DefaultAlarmDelegate() {} | 42 virtual ~DefaultAlarmDelegate() {} |
| 43 | 43 |
| 44 virtual void OnAlarm(const std::string& extension_id, | 44 virtual void OnAlarm(const std::string& extension_id, |
| 45 const Alarm& alarm) OVERRIDE { | 45 const Alarm& alarm) override { |
| 46 scoped_ptr<base::ListValue> args(new base::ListValue()); | 46 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 47 args->Append(alarm.js_alarm->ToValue().release()); | 47 args->Append(alarm.js_alarm->ToValue().release()); |
| 48 scoped_ptr<Event> event(new Event(alarms::OnAlarm::kEventName, | 48 scoped_ptr<Event> event(new Event(alarms::OnAlarm::kEventName, |
| 49 args.Pass())); | 49 args.Pass())); |
| 50 EventRouter::Get(browser_context_) | 50 EventRouter::Get(browser_context_) |
| 51 ->DispatchEventToExtension(extension_id, event.Pass()); | 51 ->DispatchEventToExtension(extension_id, event.Pass()); |
| 52 } | 52 } |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 content::BrowserContext* browser_context_; | 55 content::BrowserContext* browser_context_; |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 if (create_info.period_in_minutes.get()) { | 462 if (create_info.period_in_minutes.get()) { |
| 463 js_alarm->period_in_minutes.reset( | 463 js_alarm->period_in_minutes.reset( |
| 464 new double(*create_info.period_in_minutes)); | 464 new double(*create_info.period_in_minutes)); |
| 465 } | 465 } |
| 466 } | 466 } |
| 467 | 467 |
| 468 Alarm::~Alarm() { | 468 Alarm::~Alarm() { |
| 469 } | 469 } |
| 470 | 470 |
| 471 } // namespace extensions | 471 } // namespace extensions |
| OLD | NEW |