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

Side by Side Diff: chrome/browser/extensions/settings/settings_api.cc

Issue 8497065: Extension Settings API: make it so that when leveldb storage areas fail to be (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
6
5 #include "base/bind.h" 7 #include "base/bind.h"
6 #include "base/values.h" 8 #include "base/values.h"
7 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/settings/settings_api.h" 10 #include "chrome/browser/extensions/settings/settings_frontend.h"
9 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
10 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
11 13
12 namespace extensions { 14 namespace extensions {
13 15
14 using content::BrowserThread; 16 using content::BrowserThread;
15 17
16 namespace { 18 namespace {
17 const char* kUnsupportedArgumentType = "Unsupported argument type"; 19 const char* kUnsupportedArgumentType = "Unsupported argument type";
18 } // namespace 20 } // namespace
19 21
20 // SettingsFunction 22 // SettingsFunction
21 23
22 bool SettingsFunction::RunImpl() { 24 bool SettingsFunction::RunImpl() {
23 SettingsFrontend* frontend = 25 SettingsFrontend* frontend =
24 profile()->GetExtensionService()->settings_frontend(); 26 profile()->GetExtensionService()->settings_frontend();
25 frontend->RunWithStorage( 27 frontend->RunWithStorage(
26 extension_id(), 28 extension_id(),
27 base::Bind( 29 base::Bind(
28 &SettingsFunction::RunWithStorageOnFileThread, 30 &SettingsFunction::RunWithStorageOnFileThread,
29 this, 31 this,
30 frontend->GetObservers())); 32 frontend->GetObservers()));
31 return true; 33 return true;
32 } 34 }
33 35
34 void SettingsFunction::RunWithStorageOnFileThread( 36 void SettingsFunction::RunWithStorageOnFileThread(
35 scoped_refptr<SettingsObserverList> observers, 37 scoped_refptr<SettingsObserverList> observers,
36 SettingsStorage* storage) { 38 SettingsStorage* storage) {
37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
38 bool success = false; 40 bool success = RunWithStorage(observers.get(), storage);
39 if (storage) {
40 success = RunWithStorage(observers.get(), storage);
41 }
42 BrowserThread::PostTask( 41 BrowserThread::PostTask(
43 BrowserThread::UI, 42 BrowserThread::UI,
44 FROM_HERE, 43 FROM_HERE,
45 base::Bind(&SettingsFunction::SendResponse, this, success)); 44 base::Bind(&SettingsFunction::SendResponse, this, success));
46 } 45 }
47 46
48 bool SettingsFunction::UseReadResult( 47 bool SettingsFunction::UseReadResult(
49 const SettingsStorage::ReadResult& result) { 48 const SettingsStorage::ReadResult& result) {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
51 if (result.HasError()) { 50 if (result.HasError()) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 179 }
181 180
182 bool ClearSettingsFunction::RunWithStorage( 181 bool ClearSettingsFunction::RunWithStorage(
183 scoped_refptr<SettingsObserverList> observers, 182 scoped_refptr<SettingsObserverList> observers,
184 SettingsStorage* storage) { 183 SettingsStorage* storage) {
185 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 184 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
186 return UseWriteResult(observers, storage->Clear()); 185 return UseWriteResult(observers, storage->Clear());
187 } 186 }
188 187
189 } // namespace extensions 188 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698