| OLD | NEW |
| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 | 72 |
| 73 ExtensionFunction::ResponseValue SettingsFunction::UseReadResult( | 73 ExtensionFunction::ResponseValue SettingsFunction::UseReadResult( |
| 74 ValueStore::ReadResult result, | 74 ValueStore::ReadResult result, |
| 75 ValueStore* storage) { | 75 ValueStore* storage) { |
| 76 if (result->HasError()) | 76 if (result->HasError()) |
| 77 return HandleError(result->error(), storage); | 77 return HandleError(result->error(), storage); |
| 78 | 78 |
| 79 base::DictionaryValue* dict = new base::DictionaryValue(); | 79 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 80 dict->Swap(&result->settings()); | 80 dict->Swap(&result->settings()); |
| 81 return SingleArgument(dict); | 81 return OneArgument(dict); |
| 82 } | 82 } |
| 83 | 83 |
| 84 ExtensionFunction::ResponseValue SettingsFunction::UseWriteResult( | 84 ExtensionFunction::ResponseValue SettingsFunction::UseWriteResult( |
| 85 ValueStore::WriteResult result, | 85 ValueStore::WriteResult result, |
| 86 ValueStore* storage) { | 86 ValueStore* storage) { |
| 87 if (result->HasError()) | 87 if (result->HasError()) |
| 88 return HandleError(result->error(), storage); | 88 return HandleError(result->error(), storage); |
| 89 | 89 |
| 90 if (!result->changes().empty()) { | 90 if (!result->changes().empty()) { |
| 91 observers_->Notify( | 91 observers_->Notify( |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 AddAllStringValues(*static_cast<base::ListValue*>(input), | 242 AddAllStringValues(*static_cast<base::ListValue*>(input), |
| 243 &as_string_list); | 243 &as_string_list); |
| 244 bytes_in_use = storage->GetBytesInUse(as_string_list); | 244 bytes_in_use = storage->GetBytesInUse(as_string_list); |
| 245 break; | 245 break; |
| 246 } | 246 } |
| 247 | 247 |
| 248 default: | 248 default: |
| 249 return BadMessage(); | 249 return BadMessage(); |
| 250 } | 250 } |
| 251 | 251 |
| 252 return SingleArgument( | 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 = NULL; |
| 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 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |