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

Side by Side Diff: chrome/browser/value_store/value_store_frontend.cc

Issue 10545128: Unrevert r141537: Add extensions::StateStore and use that instead of (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
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/value_store/value_store_frontend.h" 5 #include "chrome/browser/value_store/value_store_frontend.h"
6 6
7 #include "chrome/browser/value_store/failing_value_store.h"
7 #include "chrome/browser/value_store/leveldb_value_store.h" 8 #include "chrome/browser/value_store/leveldb_value_store.h"
8 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
9 10
10 using content::BrowserThread; 11 using content::BrowserThread;
11 12
12 class ValueStoreFrontend::Backend : public base::RefCountedThreadSafe<Backend> { 13 class ValueStoreFrontend::Backend : public base::RefCountedThreadSafe<Backend> {
13 public: 14 public:
14 explicit Backend(const FilePath& db_path) : storage_(NULL) { 15 explicit Backend(const FilePath& db_path) : storage_(NULL) {
15 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 16 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
16 base::Bind(&ValueStoreFrontend::Backend::InitOnFileThread, 17 base::Bind(&ValueStoreFrontend::Backend::InitOnFileThread,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 delete storage_; 55 delete storage_;
55 } else { 56 } else {
56 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, storage_); 57 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, storage_);
57 } 58 }
58 } 59 }
59 60
60 void InitOnFileThread(const FilePath& db_path) { 61 void InitOnFileThread(const FilePath& db_path) {
61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
62 DCHECK(!storage_); 63 DCHECK(!storage_);
63 storage_ = LeveldbValueStore::Create(db_path); 64 storage_ = LeveldbValueStore::Create(db_path);
65 if (!storage_)
66 storage_ = new FailingValueStore();
Matt Perry 2012/06/12 00:15:57 This is the main difference. I also renamed Faili
64 } 67 }
65 68
66 void RunCallback(const ValueStoreFrontend::ReadCallback& callback, 69 void RunCallback(const ValueStoreFrontend::ReadCallback& callback,
67 scoped_ptr<base::Value> value) { 70 scoped_ptr<base::Value> value) {
68 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
69 callback.Run(value.Pass()); 72 callback.Run(value.Pass());
70 } 73 }
71 74
72 // The actual ValueStore that handles persisting the data to disk. Used 75 // The actual ValueStore that handles persisting the data to disk. Used
73 // exclusively on the FILE thread. 76 // exclusively on the FILE thread.
74 LeveldbValueStore* storage_; 77 ValueStore* storage_;
75 78
76 DISALLOW_COPY_AND_ASSIGN(Backend); 79 DISALLOW_COPY_AND_ASSIGN(Backend);
77 }; 80 };
78 81
79 ValueStoreFrontend::ValueStoreFrontend(const FilePath& db_path) 82 ValueStoreFrontend::ValueStoreFrontend(const FilePath& db_path)
80 : backend_(new Backend(db_path)) { 83 : backend_(new Backend(db_path)) {
81 } 84 }
82 85
83 ValueStoreFrontend::~ValueStoreFrontend() { 86 ValueStoreFrontend::~ValueStoreFrontend() {
84 DCHECK(CalledOnValidThread()); 87 DCHECK(CalledOnValidThread());
(...skipping 17 matching lines...) Expand all
102 backend_, key, base::Passed(value.Pass()))); 105 backend_, key, base::Passed(value.Pass())));
103 } 106 }
104 107
105 void ValueStoreFrontend::Remove(const std::string& key) { 108 void ValueStoreFrontend::Remove(const std::string& key) {
106 DCHECK(CalledOnValidThread()); 109 DCHECK(CalledOnValidThread());
107 110
108 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 111 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
109 base::Bind(&ValueStoreFrontend::Backend::Remove, 112 base::Bind(&ValueStoreFrontend::Backend::Remove,
110 backend_, key)); 113 backend_, key));
111 } 114 }
OLDNEW
« no previous file with comments | « chrome/browser/value_store/failing_value_store.cc ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698