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

Side by Side Diff: extensions/browser/api/storage/storage_api.cc

Issue 598173003: Run clang-modernize -use-nullptr over src/extensions/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/storage/storage_api.h" 5 #include "extensions/browser/api/storage/storage_api.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 23 matching lines...) Expand all
34 // This should be EXTENSION_FUNCTION_VALIDATE(false) but there is no way 34 // This should be EXTENSION_FUNCTION_VALIDATE(false) but there is no way
35 // to signify that from this function. It will be caught in Run(). 35 // to signify that from this function. It will be caught in Run().
36 return false; 36 return false;
37 } 37 }
38 return settings_namespace_string != "sync"; 38 return settings_namespace_string != "sync";
39 } 39 }
40 40
41 ExtensionFunction::ResponseAction SettingsFunction::Run() { 41 ExtensionFunction::ResponseAction SettingsFunction::Run() {
42 std::string settings_namespace_string; 42 std::string settings_namespace_string;
43 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &settings_namespace_string)); 43 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &settings_namespace_string));
44 args_->Remove(0, NULL); 44 args_->Remove(0, nullptr);
45 settings_namespace_ = 45 settings_namespace_ =
46 settings_namespace::FromString(settings_namespace_string); 46 settings_namespace::FromString(settings_namespace_string);
47 EXTENSION_FUNCTION_VALIDATE(settings_namespace_ != 47 EXTENSION_FUNCTION_VALIDATE(settings_namespace_ !=
48 settings_namespace::INVALID); 48 settings_namespace::INVALID);
49 49
50 StorageFrontend* frontend = StorageFrontend::Get(browser_context()); 50 StorageFrontend* frontend = StorageFrontend::Get(browser_context());
51 if (!frontend->IsStorageEnabled(settings_namespace_)) { 51 if (!frontend->IsStorageEnabled(settings_namespace_)) {
52 return RespondNow(Error( 52 return RespondNow(Error(
53 base::StringPrintf("\"%s\" is not available in this instance of Chrome", 53 base::StringPrintf("\"%s\" is not available in this instance of Chrome",
54 settings_namespace_string.c_str()))); 54 settings_namespace_string.c_str())));
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 base::TimeDelta::FromMinutes(10), 169 base::TimeDelta::FromMinutes(10),
170 shortLimitConfig, 170 shortLimitConfig,
171 new QuotaLimitHeuristic::SingletonBucketMapper(), 171 new QuotaLimitHeuristic::SingletonBucketMapper(),
172 "MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE")); 172 "MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE"));
173 }; 173 };
174 174
175 } // namespace 175 } // namespace
176 176
177 ExtensionFunction::ResponseValue StorageStorageAreaGetFunction::RunWithStorage( 177 ExtensionFunction::ResponseValue StorageStorageAreaGetFunction::RunWithStorage(
178 ValueStore* storage) { 178 ValueStore* storage) {
179 base::Value* input = NULL; 179 base::Value* input = nullptr;
180 if (!args_->Get(0, &input)) 180 if (!args_->Get(0, &input))
181 return BadMessage(); 181 return BadMessage();
182 182
183 switch (input->GetType()) { 183 switch (input->GetType()) {
184 case base::Value::TYPE_NULL: 184 case base::Value::TYPE_NULL:
185 return UseReadResult(storage->Get(), storage); 185 return UseReadResult(storage->Get(), storage);
186 186
187 case base::Value::TYPE_STRING: { 187 case base::Value::TYPE_STRING: {
188 std::string as_string; 188 std::string as_string;
189 input->GetAsString(&as_string); 189 input->GetAsString(&as_string);
(...skipping 22 matching lines...) Expand all
212 storage); 212 storage);
213 } 213 }
214 214
215 default: 215 default:
216 return BadMessage(); 216 return BadMessage();
217 } 217 }
218 } 218 }
219 219
220 ExtensionFunction::ResponseValue 220 ExtensionFunction::ResponseValue
221 StorageStorageAreaGetBytesInUseFunction::RunWithStorage(ValueStore* storage) { 221 StorageStorageAreaGetBytesInUseFunction::RunWithStorage(ValueStore* storage) {
222 base::Value* input = NULL; 222 base::Value* input = nullptr;
223 if (!args_->Get(0, &input)) 223 if (!args_->Get(0, &input))
224 return BadMessage(); 224 return BadMessage();
225 225
226 size_t bytes_in_use = 0; 226 size_t bytes_in_use = 0;
227 227
228 switch (input->GetType()) { 228 switch (input->GetType()) {
229 case base::Value::TYPE_NULL: 229 case base::Value::TYPE_NULL:
230 bytes_in_use = storage->GetBytesInUse(); 230 bytes_in_use = storage->GetBytesInUse();
231 break; 231 break;
232 232
(...skipping 15 matching lines...) Expand all
248 default: 248 default:
249 return BadMessage(); 249 return BadMessage();
250 } 250 }
251 251
252 return OneArgument( 252 return OneArgument(
253 new base::FundamentalValue(static_cast<int>(bytes_in_use))); 253 new base::FundamentalValue(static_cast<int>(bytes_in_use)));
254 } 254 }
255 255
256 ExtensionFunction::ResponseValue StorageStorageAreaSetFunction::RunWithStorage( 256 ExtensionFunction::ResponseValue StorageStorageAreaSetFunction::RunWithStorage(
257 ValueStore* storage) { 257 ValueStore* storage) {
258 base::DictionaryValue* input = NULL; 258 base::DictionaryValue* input = nullptr;
259 if (!args_->GetDictionary(0, &input)) 259 if (!args_->GetDictionary(0, &input))
260 return BadMessage(); 260 return BadMessage();
261 return UseWriteResult(storage->Set(ValueStore::DEFAULTS, *input), storage); 261 return UseWriteResult(storage->Set(ValueStore::DEFAULTS, *input), storage);
262 } 262 }
263 263
264 void StorageStorageAreaSetFunction::GetQuotaLimitHeuristics( 264 void StorageStorageAreaSetFunction::GetQuotaLimitHeuristics(
265 QuotaLimitHeuristics* heuristics) const { 265 QuotaLimitHeuristics* heuristics) const {
266 GetModificationQuotaLimitHeuristics(heuristics); 266 GetModificationQuotaLimitHeuristics(heuristics);
267 } 267 }
268 268
269 ExtensionFunction::ResponseValue 269 ExtensionFunction::ResponseValue
270 StorageStorageAreaRemoveFunction::RunWithStorage(ValueStore* storage) { 270 StorageStorageAreaRemoveFunction::RunWithStorage(ValueStore* storage) {
271 base::Value* input = NULL; 271 base::Value* input = nullptr;
272 if (!args_->Get(0, &input)) 272 if (!args_->Get(0, &input))
273 return BadMessage(); 273 return BadMessage();
274 274
275 switch (input->GetType()) { 275 switch (input->GetType()) {
276 case base::Value::TYPE_STRING: { 276 case base::Value::TYPE_STRING: {
277 std::string as_string; 277 std::string as_string;
278 input->GetAsString(&as_string); 278 input->GetAsString(&as_string);
279 return UseWriteResult(storage->Remove(as_string), storage); 279 return UseWriteResult(storage->Remove(as_string), storage);
280 } 280 }
281 281
(...skipping 18 matching lines...) Expand all
300 StorageStorageAreaClearFunction::RunWithStorage(ValueStore* storage) { 300 StorageStorageAreaClearFunction::RunWithStorage(ValueStore* storage) {
301 return UseWriteResult(storage->Clear(), storage); 301 return UseWriteResult(storage->Clear(), storage);
302 } 302 }
303 303
304 void StorageStorageAreaClearFunction::GetQuotaLimitHeuristics( 304 void StorageStorageAreaClearFunction::GetQuotaLimitHeuristics(
305 QuotaLimitHeuristics* heuristics) const { 305 QuotaLimitHeuristics* heuristics) const {
306 GetModificationQuotaLimitHeuristics(heuristics); 306 GetModificationQuotaLimitHeuristics(heuristics);
307 } 307 }
308 308
309 } // namespace extensions 309 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698