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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // runner. Without this, we'd get reports of memory leaks. | 67 // runner. Without this, we'd get reports of memory leaks. |
68 db_.reset(); | 68 db_.reset(); |
69 base::RunLoop().RunUntilIdle(); | 69 base::RunLoop().RunUntilIdle(); |
70 } | 70 } |
71 | 71 |
72 void CreateDatabase() { | 72 void CreateDatabase() { |
73 // Explicitly destroy any existing database first, so it releases the lock | 73 // Explicitly destroy any existing database first, so it releases the lock |
74 // on the file. | 74 // on the file. |
75 db_.reset(); | 75 db_.reset(); |
76 | 76 |
77 db_.reset(new NTPSnippetsDatabase(database_dir_.path(), | 77 db_.reset(new NTPSnippetsDatabase(database_dir_.GetPath(), |
78 base::ThreadTaskRunnerHandle::Get())); | 78 base::ThreadTaskRunnerHandle::Get())); |
79 } | 79 } |
80 | 80 |
81 NTPSnippetsDatabase* db() { return db_.get(); } | 81 NTPSnippetsDatabase* db() { return db_.get(); } |
82 | 82 |
83 void OnSnippetsLoaded(NTPSnippet::PtrVector snippets) { | 83 void OnSnippetsLoaded(NTPSnippet::PtrVector snippets) { |
84 OnSnippetsLoadedImpl(snippets); | 84 OnSnippetsLoadedImpl(snippets); |
85 } | 85 } |
86 MOCK_METHOD1(OnSnippetsLoadedImpl, | 86 MOCK_METHOD1(OnSnippetsLoadedImpl, |
87 void(const NTPSnippet::PtrVector& snippets)); | 87 void(const NTPSnippet::PtrVector& snippets)); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 280 |
281 // Make sure the image is gone. | 281 // Make sure the image is gone. |
282 EXPECT_CALL(*this, OnImageLoaded(std::string())); | 282 EXPECT_CALL(*this, OnImageLoaded(std::string())); |
283 db()->LoadImage(snippet->id(), | 283 db()->LoadImage(snippet->id(), |
284 base::Bind(&NTPSnippetsDatabaseTest::OnImageLoaded, | 284 base::Bind(&NTPSnippetsDatabaseTest::OnImageLoaded, |
285 base::Unretained(this))); | 285 base::Unretained(this))); |
286 base::RunLoop().RunUntilIdle(); | 286 base::RunLoop().RunUntilIdle(); |
287 } | 287 } |
288 | 288 |
289 } // namespace ntp_snippets | 289 } // namespace ntp_snippets |
OLD | NEW |