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

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

Issue 2038613003: Revert of ExtensionFunction: don't pass ownership of base::Value by raw pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « extensions/browser/api/runtime/runtime_api.cc ('k') | extensions/browser/api/usb/usb_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 BrowserThread::UI, 71 BrowserThread::UI,
72 FROM_HERE, 72 FROM_HERE,
73 base::Bind(&SettingsFunction::Respond, this, base::Passed(&response))); 73 base::Bind(&SettingsFunction::Respond, this, base::Passed(&response)));
74 } 74 }
75 75
76 ExtensionFunction::ResponseValue SettingsFunction::UseReadResult( 76 ExtensionFunction::ResponseValue SettingsFunction::UseReadResult(
77 ValueStore::ReadResult result) { 77 ValueStore::ReadResult result) {
78 if (!result->status().ok()) 78 if (!result->status().ok())
79 return Error(result->status().message); 79 return Error(result->status().message);
80 80
81 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 81 base::DictionaryValue* dict = new base::DictionaryValue();
82 dict->Swap(&result->settings()); 82 dict->Swap(&result->settings());
83 return OneArgument(std::move(dict)); 83 return OneArgument(dict);
84 } 84 }
85 85
86 ExtensionFunction::ResponseValue SettingsFunction::UseWriteResult( 86 ExtensionFunction::ResponseValue SettingsFunction::UseWriteResult(
87 ValueStore::WriteResult result) { 87 ValueStore::WriteResult result) {
88 if (!result->status().ok()) 88 if (!result->status().ok())
89 return Error(result->status().message); 89 return Error(result->status().message);
90 90
91 if (!result->changes().empty()) { 91 if (!result->changes().empty()) {
92 observers_->Notify(FROM_HERE, &SettingsObserver::OnSettingsChanged, 92 observers_->Notify(FROM_HERE, &SettingsObserver::OnSettingsChanged,
93 extension_id(), settings_namespace_, 93 extension_id(), settings_namespace_,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 &as_string_list); 210 &as_string_list);
211 bytes_in_use = storage->GetBytesInUse(as_string_list); 211 bytes_in_use = storage->GetBytesInUse(as_string_list);
212 break; 212 break;
213 } 213 }
214 214
215 default: 215 default:
216 return BadMessage(); 216 return BadMessage();
217 } 217 }
218 218
219 return OneArgument( 219 return OneArgument(
220 base::MakeUnique<base::FundamentalValue>(static_cast<int>(bytes_in_use))); 220 new base::FundamentalValue(static_cast<int>(bytes_in_use)));
221 } 221 }
222 222
223 ExtensionFunction::ResponseValue StorageStorageAreaSetFunction::RunWithStorage( 223 ExtensionFunction::ResponseValue StorageStorageAreaSetFunction::RunWithStorage(
224 ValueStore* storage) { 224 ValueStore* storage) {
225 base::DictionaryValue* input = NULL; 225 base::DictionaryValue* input = NULL;
226 if (!args_->GetDictionary(0, &input)) 226 if (!args_->GetDictionary(0, &input))
227 return BadMessage(); 227 return BadMessage();
228 return UseWriteResult(storage->Set(ValueStore::DEFAULTS, *input)); 228 return UseWriteResult(storage->Set(ValueStore::DEFAULTS, *input));
229 } 229 }
230 230
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 StorageStorageAreaClearFunction::RunWithStorage(ValueStore* storage) { 267 StorageStorageAreaClearFunction::RunWithStorage(ValueStore* storage) {
268 return UseWriteResult(storage->Clear()); 268 return UseWriteResult(storage->Clear());
269 } 269 }
270 270
271 void StorageStorageAreaClearFunction::GetQuotaLimitHeuristics( 271 void StorageStorageAreaClearFunction::GetQuotaLimitHeuristics(
272 QuotaLimitHeuristics* heuristics) const { 272 QuotaLimitHeuristics* heuristics) const {
273 GetModificationQuotaLimitHeuristics(heuristics); 273 GetModificationQuotaLimitHeuristics(heuristics);
274 } 274 }
275 275
276 } // namespace extensions 276 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/runtime/runtime_api.cc ('k') | extensions/browser/api/usb/usb_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698