| 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/settings/settings_api.h" | 5 #include "chrome/browser/extensions/settings/settings_api.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extensions_quota_service.h" | 10 #include "chrome/browser/extensions/extensions_quota_service.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 base::Bind(&SettingsFunction::SendResponse, this, success)); | 71 base::Bind(&SettingsFunction::SendResponse, this, success)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool SettingsFunction::UseReadResult(ValueStore::ReadResult result) { | 74 bool SettingsFunction::UseReadResult(ValueStore::ReadResult result) { |
| 75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 76 if (result->HasError()) { | 76 if (result->HasError()) { |
| 77 error_ = result->error(); | 77 error_ = result->error(); |
| 78 return false; | 78 return false; |
| 79 } | 79 } |
| 80 | 80 |
| 81 result_ = result->settings().Pass(); | 81 SetResult(result->settings().release()); |
| 82 return true; | 82 return true; |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool SettingsFunction::UseWriteResult(ValueStore::WriteResult result) { | 85 bool SettingsFunction::UseWriteResult(ValueStore::WriteResult result) { |
| 86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 87 if (result->HasError()) { | 87 if (result->HasError()) { |
| 88 error_ = result->error(); | 88 error_ = result->error(); |
| 89 return false; | 89 return false; |
| 90 } | 90 } |
| 91 | 91 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 AddAllStringValues(*static_cast<ListValue*>(input), &as_string_list); | 216 AddAllStringValues(*static_cast<ListValue*>(input), &as_string_list); |
| 217 bytes_in_use = storage->GetBytesInUse(as_string_list); | 217 bytes_in_use = storage->GetBytesInUse(as_string_list); |
| 218 break; | 218 break; |
| 219 } | 219 } |
| 220 | 220 |
| 221 default: | 221 default: |
| 222 error_ = kUnsupportedArgumentType; | 222 error_ = kUnsupportedArgumentType; |
| 223 return false; | 223 return false; |
| 224 } | 224 } |
| 225 | 225 |
| 226 result_.reset(Value::CreateIntegerValue(bytes_in_use)); | 226 SetResult(Value::CreateIntegerValue(bytes_in_use)); |
| 227 return true; | 227 return true; |
| 228 } | 228 } |
| 229 | 229 |
| 230 bool SetSettingsFunction::RunWithStorage(ValueStore* storage) { | 230 bool SetSettingsFunction::RunWithStorage(ValueStore* storage) { |
| 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 232 DictionaryValue* input = NULL; | 232 DictionaryValue* input = NULL; |
| 233 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &input)); | 233 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &input)); |
| 234 return UseWriteResult(storage->Set(ValueStore::DEFAULTS, *input)); | 234 return UseWriteResult(storage->Set(ValueStore::DEFAULTS, *input)); |
| 235 } | 235 } |
| 236 | 236 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 273 return UseWriteResult(storage->Clear()); | 273 return UseWriteResult(storage->Clear()); |
| 274 } | 274 } |
| 275 | 275 |
| 276 void ClearSettingsFunction::GetQuotaLimitHeuristics( | 276 void ClearSettingsFunction::GetQuotaLimitHeuristics( |
| 277 QuotaLimitHeuristics* heuristics) const { | 277 QuotaLimitHeuristics* heuristics) const { |
| 278 GetModificationQuotaLimitHeuristics(heuristics); | 278 GetModificationQuotaLimitHeuristics(heuristics); |
| 279 } | 279 } |
| 280 | 280 |
| 281 } // namespace extensions | 281 } // namespace extensions |
| OLD | NEW |