Chromium Code Reviews| 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/alarms_api.h" | 5 #include "chrome/browser/extensions/api/alarms/alarms_api.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/time/clock.h" | 8 #include "base/time/clock.h" |
| 9 #include "base/time/default_clock.h" | 9 #include "base/time/default_clock.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 std::string name = params->name.get() ? *params->name : kDefaultAlarmName; | 182 std::string name = params->name.get() ? *params->name : kDefaultAlarmName; |
| 183 AlarmManager::Get(GetProfile()) | 183 AlarmManager::Get(GetProfile()) |
| 184 ->RemoveAlarm(extension_id(), | 184 ->RemoveAlarm(extension_id(), |
| 185 name, | 185 name, |
| 186 base::Bind(&AlarmsClearFunction::Callback, this, name)); | 186 base::Bind(&AlarmsClearFunction::Callback, this, name)); |
| 187 | 187 |
| 188 return true; | 188 return true; |
| 189 } | 189 } |
| 190 | 190 |
| 191 void AlarmsClearFunction::Callback(const std::string& name, bool success) { | 191 void AlarmsClearFunction::Callback(const std::string& name, bool success) { |
| 192 if (!success) | 192 SetResult(new base::FundamentalValue(success)); |
| 193 error_ = ErrorUtils::FormatErrorMessage(kAlarmNotFound, name); | 193 SendResponse(true); |
| 194 | |
| 195 SendResponse(success); | |
| 196 } | 194 } |
| 197 | 195 |
| 198 bool AlarmsClearAllFunction::RunImpl() { | 196 bool AlarmsClearAllFunction::RunImpl() { |
| 199 AlarmManager::Get(GetProfile())->RemoveAllAlarms( | 197 AlarmManager::Get(GetProfile())->RemoveAllAlarms( |
| 200 extension_id(), base::Bind(&AlarmsClearAllFunction::Callback, this)); | 198 extension_id(), base::Bind(&AlarmsClearAllFunction::Callback, this)); |
| 201 return true; | 199 return true; |
| 202 } | 200 } |
| 203 | 201 |
| 204 void AlarmsClearAllFunction::Callback() { | 202 void AlarmsClearAllFunction::Callback() { |
| 203 SetResult(new base::FundamentalValue(true)); | |
|
not at google - send to devlin
2014/03/20 10:52:21
seems more correct to set this to (num_alarms_clea
Matt Perry
2014/03/20 18:53:42
hmm.. I think generally removeAll() on the empty s
robliao
2014/03/20 19:01:05
There are two philosophies to take here:
1) We tre
Matt Perry
2014/03/20 21:07:00
Yeah, #1 makes more sense IMO. I think it should o
robliao
2014/03/20 21:20:30
We do a hard CHECK if that happens, so we should b
| |
| 205 SendResponse(true); | 204 SendResponse(true); |
| 206 } | 205 } |
| 207 | 206 |
| 208 } // namespace extensions | 207 } // namespace extensions |
| OLD | NEW |