| OLD | NEW |
| 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 "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" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 void Get(const std::string& key, | 35 void Get(const std::string& key, |
| 36 const ValueStoreFrontend::ReadCallback& callback) { | 36 const ValueStoreFrontend::ReadCallback& callback) { |
| 37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 38 ValueStore::ReadResult result = storage_->Get(key); | 38 ValueStore::ReadResult result = storage_->Get(key); |
| 39 | 39 |
| 40 // Extract the value from the ReadResult and pass ownership of it to the | 40 // Extract the value from the ReadResult and pass ownership of it to the |
| 41 // callback. | 41 // callback. |
| 42 scoped_ptr<base::Value> value; | 42 scoped_ptr<base::Value> value; |
| 43 if (!result->HasError()) { | 43 if (!result->HasError()) { |
| 44 result->settings()->RemoveWithoutPathExpansion(key, &value); | 44 result->settings().RemoveWithoutPathExpansion(key, &value); |
| 45 } else { | 45 } else { |
| 46 LOG(INFO) << "Reading " << key << " from " << db_path_.value() | 46 LOG(WARNING) << "Reading " << key << " from " << db_path_.value() |
| 47 << " failed: " << result->error(); | 47 << " failed: " << result->error().message; |
| 48 } | 48 } |
| 49 | 49 |
| 50 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 50 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 51 base::Bind(&ValueStoreFrontend::Backend::RunCallback, | 51 base::Bind(&ValueStoreFrontend::Backend::RunCallback, |
| 52 this, callback, base::Passed(&value))); | 52 this, callback, base::Passed(&value))); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void Set(const std::string& key, scoped_ptr<base::Value> value) { | 55 void Set(const std::string& key, scoped_ptr<base::Value> value) { |
| 56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 57 // We don't need the old value, so skip generating changes. | 57 // We don't need the old value, so skip generating changes. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 backend_, key, base::Passed(&value))); | 134 backend_, key, base::Passed(&value))); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void ValueStoreFrontend::Remove(const std::string& key) { | 137 void ValueStoreFrontend::Remove(const std::string& key) { |
| 138 DCHECK(CalledOnValidThread()); | 138 DCHECK(CalledOnValidThread()); |
| 139 | 139 |
| 140 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 140 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 141 base::Bind(&ValueStoreFrontend::Backend::Remove, | 141 base::Bind(&ValueStoreFrontend::Backend::Remove, |
| 142 backend_, key)); | 142 backend_, key)); |
| 143 } | 143 } |
| OLD | NEW |