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

Side by Side Diff: extensions/browser/api/alarms/alarm_manager.cc

Issue 2051663003: base::ListValue::Append cleanup: pass unique_ptr instead of the released pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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
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 #include "extensions/browser/api/alarms/alarm_manager.h" 5 #include "extensions/browser/api/alarms/alarm_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 class DefaultAlarmDelegate : public AlarmManager::Delegate { 41 class DefaultAlarmDelegate : public AlarmManager::Delegate {
42 public: 42 public:
43 explicit DefaultAlarmDelegate(content::BrowserContext* context) 43 explicit DefaultAlarmDelegate(content::BrowserContext* context)
44 : browser_context_(context) {} 44 : browser_context_(context) {}
45 ~DefaultAlarmDelegate() override {} 45 ~DefaultAlarmDelegate() override {}
46 46
47 void OnAlarm(const std::string& extension_id, const Alarm& alarm) override { 47 void OnAlarm(const std::string& extension_id, const Alarm& alarm) override {
48 std::unique_ptr<base::ListValue> args(new base::ListValue()); 48 std::unique_ptr<base::ListValue> args(new base::ListValue());
49 args->Append(alarm.js_alarm->ToValue().release()); 49 args->Append(alarm.js_alarm->ToValue());
50 std::unique_ptr<Event> event(new Event( 50 std::unique_ptr<Event> event(new Event(
51 events::ALARMS_ON_ALARM, alarms::OnAlarm::kEventName, std::move(args))); 51 events::ALARMS_ON_ALARM, alarms::OnAlarm::kEventName, std::move(args)));
52 EventRouter::Get(browser_context_) 52 EventRouter::Get(browser_context_)
53 ->DispatchEventToExtension(extension_id, std::move(event)); 53 ->DispatchEventToExtension(extension_id, std::move(event));
54 } 54 }
55 55
56 private: 56 private:
57 content::BrowserContext* browser_context_; 57 content::BrowserContext* browser_context_;
58 }; 58 };
59 59
(...skipping 20 matching lines...) Expand all
80 } 80 }
81 81
82 std::unique_ptr<base::ListValue> AlarmsToValue( 82 std::unique_ptr<base::ListValue> AlarmsToValue(
83 const std::vector<Alarm>& alarms) { 83 const std::vector<Alarm>& alarms) {
84 std::unique_ptr<base::ListValue> list(new base::ListValue()); 84 std::unique_ptr<base::ListValue> list(new base::ListValue());
85 for (size_t i = 0; i < alarms.size(); ++i) { 85 for (size_t i = 0; i < alarms.size(); ++i) {
86 std::unique_ptr<base::DictionaryValue> alarm = 86 std::unique_ptr<base::DictionaryValue> alarm =
87 alarms[i].js_alarm->ToValue(); 87 alarms[i].js_alarm->ToValue();
88 alarm->Set(kAlarmGranularity, 88 alarm->Set(kAlarmGranularity,
89 base::CreateTimeDeltaValue(alarms[i].granularity)); 89 base::CreateTimeDeltaValue(alarms[i].granularity));
90 list->Append(alarm.release()); 90 list->Append(std::move(alarm));
91 } 91 }
92 return list; 92 return list;
93 } 93 }
94 94
95 } // namespace 95 } // namespace
96 96
97 // AlarmManager 97 // AlarmManager
98 98
99 AlarmManager::AlarmManager(content::BrowserContext* context) 99 AlarmManager::AlarmManager(content::BrowserContext* context)
100 : browser_context_(context), 100 : browser_context_(context),
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 new double(*create_info.period_in_minutes)); 466 new double(*create_info.period_in_minutes));
467 } 467 }
468 } 468 }
469 469
470 Alarm::Alarm(const Alarm& other) = default; 470 Alarm::Alarm(const Alarm& other) = default;
471 471
472 Alarm::~Alarm() { 472 Alarm::~Alarm() {
473 } 473 }
474 474
475 } // namespace extensions 475 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698