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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "extensions/browser/value_store/leveldb_value_store.h" | 12 #include "extensions/browser/value_store/leveldb_value_store.h" |
13 | 13 |
14 using content::BrowserThread; | 14 using content::BrowserThread; |
15 | 15 |
16 class ValueStoreFrontend::Backend : public base::RefCountedThreadSafe<Backend> { | 16 class ValueStoreFrontend::Backend : public base::RefCountedThreadSafe<Backend> { |
17 public: | 17 public: |
18 Backend() : storage_(NULL) {} | 18 Backend() : storage_(nullptr) {} |
19 | 19 |
20 void Init(const base::FilePath& db_path) { | 20 void Init(const base::FilePath& db_path) { |
21 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 21 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
22 DCHECK(!storage_); | 22 DCHECK(!storage_); |
23 TRACE_EVENT0("ValueStoreFrontend::Backend", "Init"); | 23 TRACE_EVENT0("ValueStoreFrontend::Backend", "Init"); |
24 db_path_ = db_path; | 24 db_path_ = db_path; |
25 storage_ = new LeveldbValueStore(db_path); | 25 storage_ = new LeveldbValueStore(db_path); |
26 } | 26 } |
27 | 27 |
28 // This variant is useful for testing (using a mock ValueStore). | 28 // This variant is useful for testing (using a mock ValueStore). |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 backend_, key, base::Passed(&value))); | 138 backend_, key, base::Passed(&value))); |
139 } | 139 } |
140 | 140 |
141 void ValueStoreFrontend::Remove(const std::string& key) { | 141 void ValueStoreFrontend::Remove(const std::string& key) { |
142 DCHECK(CalledOnValidThread()); | 142 DCHECK(CalledOnValidThread()); |
143 | 143 |
144 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 144 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
145 base::Bind(&ValueStoreFrontend::Backend::Remove, | 145 base::Bind(&ValueStoreFrontend::Backend::Remove, |
146 backend_, key)); | 146 backend_, key)); |
147 } | 147 } |
OLD | NEW |