| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/ntp_snippets/ntp_snippets_database.h" | 5 #include "components/ntp_snippets/ntp_snippets_database.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "components/leveldb_proto/proto_database_impl.h" | 10 #include "components/leveldb_proto/proto_database_impl.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 database_->Init(kDatabaseUMAClientName, snippet_dir, | 40 database_->Init(kDatabaseUMAClientName, snippet_dir, |
| 41 base::Bind(&NTPSnippetsDatabase::OnDatabaseInited, | 41 base::Bind(&NTPSnippetsDatabase::OnDatabaseInited, |
| 42 weak_ptr_factory_.GetWeakPtr())); | 42 weak_ptr_factory_.GetWeakPtr())); |
| 43 | 43 |
| 44 base::FilePath image_dir = database_dir.AppendASCII(kImageDatabaseFolder); | 44 base::FilePath image_dir = database_dir.AppendASCII(kImageDatabaseFolder); |
| 45 image_database_->Init(kImageDatabaseUMAClientName, image_dir, | 45 image_database_->Init(kImageDatabaseUMAClientName, image_dir, |
| 46 base::Bind(&NTPSnippetsDatabase::OnImageDatabaseInited, | 46 base::Bind(&NTPSnippetsDatabase::OnImageDatabaseInited, |
| 47 weak_ptr_factory_.GetWeakPtr())); | 47 weak_ptr_factory_.GetWeakPtr())); |
| 48 } | 48 } |
| 49 | 49 |
| 50 NTPSnippetsDatabase::~NTPSnippetsDatabase() {} | 50 NTPSnippetsDatabase::~NTPSnippetsDatabase() = default; |
| 51 | 51 |
| 52 bool NTPSnippetsDatabase::IsInitialized() const { | 52 bool NTPSnippetsDatabase::IsInitialized() const { |
| 53 return !IsErrorState() && database_initialized_ && | 53 return !IsErrorState() && database_initialized_ && |
| 54 image_database_initialized_; | 54 image_database_initialized_; |
| 55 } | 55 } |
| 56 | 56 |
| 57 bool NTPSnippetsDatabase::IsErrorState() const { | 57 bool NTPSnippetsDatabase::IsErrorState() const { |
| 58 return !database_ || !image_database_; | 58 return !database_ || !image_database_; |
| 59 } | 59 } |
| 60 | 60 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 std::unique_ptr<std::vector<std::string>> keys_to_remove) { | 284 std::unique_ptr<std::vector<std::string>> keys_to_remove) { |
| 285 DCHECK(IsInitialized()); | 285 DCHECK(IsInitialized()); |
| 286 | 286 |
| 287 image_database_->UpdateEntries( | 287 image_database_->UpdateEntries( |
| 288 base::MakeUnique<ImageKeyEntryVector>(), std::move(keys_to_remove), | 288 base::MakeUnique<ImageKeyEntryVector>(), std::move(keys_to_remove), |
| 289 base::Bind(&NTPSnippetsDatabase::OnImageDatabaseSaved, | 289 base::Bind(&NTPSnippetsDatabase::OnImageDatabaseSaved, |
| 290 weak_ptr_factory_.GetWeakPtr())); | 290 weak_ptr_factory_.GetWeakPtr())); |
| 291 } | 291 } |
| 292 | 292 |
| 293 } // namespace ntp_snippets | 293 } // namespace ntp_snippets |
| OLD | NEW |