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/value_store/value_store_frontend.h" | 5 #include "extensions/browser/value_store/value_store_frontend.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 std::unique_ptr<ValueStore> storage_; | 102 std::unique_ptr<ValueStore> storage_; |
103 | 103 |
104 base::FilePath db_path_; | 104 base::FilePath db_path_; |
105 | 105 |
106 DISALLOW_COPY_AND_ASSIGN(Backend); | 106 DISALLOW_COPY_AND_ASSIGN(Backend); |
107 }; | 107 }; |
108 | 108 |
109 ValueStoreFrontend::ValueStoreFrontend( | 109 ValueStoreFrontend::ValueStoreFrontend( |
110 const scoped_refptr<ValueStoreFactory>& store_factory, | 110 const scoped_refptr<ValueStoreFactory>& store_factory, |
111 BackendType backend_type) | 111 BackendType backend_type) |
112 : backend_(new Backend(store_factory, backend_type)) {} | 112 : backend_(new Backend(store_factory, backend_type)) { |
| 113 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 114 } |
113 | 115 |
114 ValueStoreFrontend::~ValueStoreFrontend() { | 116 ValueStoreFrontend::~ValueStoreFrontend() { |
115 DCHECK(CalledOnValidThread()); | 117 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
116 } | 118 } |
117 | 119 |
118 void ValueStoreFrontend::Get(const std::string& key, | 120 void ValueStoreFrontend::Get(const std::string& key, |
119 const ReadCallback& callback) { | 121 const ReadCallback& callback) { |
120 DCHECK(CalledOnValidThread()); | 122 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
121 | 123 |
122 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 124 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
123 base::Bind(&ValueStoreFrontend::Backend::Get, | 125 base::Bind(&ValueStoreFrontend::Backend::Get, |
124 backend_, key, callback)); | 126 backend_, key, callback)); |
125 } | 127 } |
126 | 128 |
127 void ValueStoreFrontend::Set(const std::string& key, | 129 void ValueStoreFrontend::Set(const std::string& key, |
128 std::unique_ptr<base::Value> value) { | 130 std::unique_ptr<base::Value> value) { |
129 DCHECK(CalledOnValidThread()); | 131 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
130 | 132 |
131 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 133 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
132 base::Bind(&ValueStoreFrontend::Backend::Set, | 134 base::Bind(&ValueStoreFrontend::Backend::Set, |
133 backend_, key, base::Passed(&value))); | 135 backend_, key, base::Passed(&value))); |
134 } | 136 } |
135 | 137 |
136 void ValueStoreFrontend::Remove(const std::string& key) { | 138 void ValueStoreFrontend::Remove(const std::string& key) { |
137 DCHECK(CalledOnValidThread()); | 139 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
138 | 140 |
139 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 141 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
140 base::Bind(&ValueStoreFrontend::Backend::Remove, | 142 base::Bind(&ValueStoreFrontend::Backend::Remove, |
141 backend_, key)); | 143 backend_, key)); |
142 } | 144 } |
OLD | NEW |