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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 43 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
44 base::Bind(&ValueStoreFrontend::Backend::RunCallback, | 44 base::Bind(&ValueStoreFrontend::Backend::RunCallback, |
45 this, callback, base::Passed(&value))); | 45 this, callback, base::Passed(&value))); |
46 } | 46 } |
47 | 47 |
48 void Set(const std::string& key, std::unique_ptr<base::Value> value) { | 48 void Set(const std::string& key, std::unique_ptr<base::Value> value) { |
49 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 49 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
50 LazyInit(); | 50 LazyInit(); |
51 // We don't need the old value, so skip generating changes. | 51 // We don't need the old value, so skip generating changes. |
52 ValueStore::WriteResult result = storage_->Set( | 52 ValueStore::WriteResult result = storage_->Set( |
53 ValueStore::IGNORE_QUOTA | ValueStore::NO_GENERATE_CHANGES, | 53 ValueStore::IGNORE_QUOTA | ValueStore::NO_GENERATE_CHANGES, key, |
54 key, | 54 *value); |
55 *value.get()); | |
56 LOG_IF(ERROR, !result->status().ok()) << "Error while writing " << key | 55 LOG_IF(ERROR, !result->status().ok()) << "Error while writing " << key |
57 << " to " << db_path_.value(); | 56 << " to " << db_path_.value(); |
58 } | 57 } |
59 | 58 |
60 void Remove(const std::string& key) { | 59 void Remove(const std::string& key) { |
61 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 60 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
62 LazyInit(); | 61 LazyInit(); |
63 storage_->Remove(key); | 62 storage_->Remove(key); |
64 } | 63 } |
65 | 64 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 backend_, key, base::Passed(&value))); | 133 backend_, key, base::Passed(&value))); |
135 } | 134 } |
136 | 135 |
137 void ValueStoreFrontend::Remove(const std::string& key) { | 136 void ValueStoreFrontend::Remove(const std::string& key) { |
138 DCHECK(CalledOnValidThread()); | 137 DCHECK(CalledOnValidThread()); |
139 | 138 |
140 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 139 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
141 base::Bind(&ValueStoreFrontend::Backend::Remove, | 140 base::Bind(&ValueStoreFrontend::Backend::Remove, |
142 backend_, key)); | 141 backend_, key)); |
143 } | 142 } |
OLD | NEW |