OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 HistoryService::DownloadQueryCallback download_query_callback_; | 128 HistoryService::DownloadQueryCallback download_query_callback_; |
129 | 129 |
130 private: | 130 private: |
131 void QueryDownloads( | 131 void QueryDownloads( |
132 const HistoryService::DownloadQueryCallback& callback) override { | 132 const HistoryService::DownloadQueryCallback& callback) override { |
133 download_query_callback_ = callback; | 133 download_query_callback_ = callback; |
134 } | 134 } |
135 }; | 135 }; |
136 | 136 |
137 // Constructs and returns a TestDownloadService. | 137 // Constructs and returns a TestDownloadService. |
138 static KeyedService* TestingDownloadServiceFactory( | 138 static scoped_ptr<KeyedService> TestingDownloadServiceFactory( |
139 content::BrowserContext* browser_context); | 139 content::BrowserContext* browser_context); |
140 | 140 |
141 scoped_ptr<MockDownloadManager> manager_; | 141 scoped_ptr<MockDownloadManager> manager_; |
142 content::DownloadManager::Observer* download_history_manager_observer_; | 142 content::DownloadManager::Observer* download_history_manager_observer_; |
143 content::DownloadManager::Observer* manager_observer_; | 143 content::DownloadManager::Observer* manager_observer_; |
144 content::DownloadItem* notified_item_; | 144 content::DownloadItem* notified_item_; |
145 base::WeakPtrFactory<content::DownloadItem*> notified_item_receiver_factory_; | 145 base::WeakPtrFactory<content::DownloadItem*> notified_item_receiver_factory_; |
146 | 146 |
147 HistoryAdapter* history_adapter_; | 147 HistoryAdapter* history_adapter_; |
148 }; | 148 }; |
149 | 149 |
150 // static | 150 // static |
151 KeyedService* DownloadUIControllerTest::TestingDownloadServiceFactory( | 151 scoped_ptr<KeyedService> |
| 152 DownloadUIControllerTest::TestingDownloadServiceFactory( |
152 content::BrowserContext* browser_context) { | 153 content::BrowserContext* browser_context) { |
153 return new TestDownloadService(Profile::FromBrowserContext(browser_context)); | 154 return make_scoped_ptr( |
| 155 new TestDownloadService(Profile::FromBrowserContext(browser_context))); |
154 } | 156 } |
155 | 157 |
156 DownloadUIControllerTest::DownloadUIControllerTest() | 158 DownloadUIControllerTest::DownloadUIControllerTest() |
157 : download_history_manager_observer_(NULL), | 159 : download_history_manager_observer_(NULL), |
158 manager_observer_(NULL), | 160 manager_observer_(NULL), |
159 notified_item_(NULL), | 161 notified_item_(NULL), |
160 notified_item_receiver_factory_(¬ified_item_) { | 162 notified_item_receiver_factory_(¬ified_item_) { |
161 } | 163 } |
162 | 164 |
163 void DownloadUIControllerTest::SetUp() { | 165 void DownloadUIControllerTest::SetUp() { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 // DownloadUIController. It should ignore the download since it's marked as | 340 // DownloadUIController. It should ignore the download since it's marked as |
339 // being restored from history. | 341 // being restored from history. |
340 ASSERT_TRUE(manager_observer()); | 342 ASSERT_TRUE(manager_observer()); |
341 manager_observer()->OnDownloadCreated(manager(), item.get()); | 343 manager_observer()->OnDownloadCreated(manager(), item.get()); |
342 | 344 |
343 // Finally, the expectation we've been waiting for: | 345 // Finally, the expectation we've been waiting for: |
344 EXPECT_FALSE(notified_item()); | 346 EXPECT_FALSE(notified_item()); |
345 } | 347 } |
346 | 348 |
347 } // namespace | 349 } // namespace |
OLD | NEW |