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 "content/browser/download/download_manager_impl.h" | 5 #include "content/browser/download/download_manager_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <map> |
10 #include <memory> | 11 #include <memory> |
11 #include <set> | 12 #include <set> |
12 #include <string> | 13 #include <string> |
13 #include <utility> | 14 #include <utility> |
14 | 15 |
15 #include "base/bind.h" | 16 #include "base/bind.h" |
16 #include "base/files/scoped_temp_dir.h" | 17 #include "base/files/scoped_temp_dir.h" |
17 #include "base/guid.h" | 18 #include "base/guid.h" |
18 #include "base/macros.h" | 19 #include "base/macros.h" |
19 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 MOCK_METHOD0(Remove, void()); | 137 MOCK_METHOD0(Remove, void()); |
137 MOCK_CONST_METHOD1(TimeRemaining, bool(base::TimeDelta*)); | 138 MOCK_CONST_METHOD1(TimeRemaining, bool(base::TimeDelta*)); |
138 MOCK_CONST_METHOD0(CurrentSpeed, int64_t()); | 139 MOCK_CONST_METHOD0(CurrentSpeed, int64_t()); |
139 MOCK_CONST_METHOD0(PercentComplete, int()); | 140 MOCK_CONST_METHOD0(PercentComplete, int()); |
140 MOCK_CONST_METHOD0(AllDataSaved, bool()); | 141 MOCK_CONST_METHOD0(AllDataSaved, bool()); |
141 MOCK_CONST_METHOD1(MatchesQuery, bool(const base::string16& query)); | 142 MOCK_CONST_METHOD1(MatchesQuery, bool(const base::string16& query)); |
142 MOCK_CONST_METHOD0(IsDone, bool()); | 143 MOCK_CONST_METHOD0(IsDone, bool()); |
143 MOCK_CONST_METHOD0(GetFullPath, const base::FilePath&()); | 144 MOCK_CONST_METHOD0(GetFullPath, const base::FilePath&()); |
144 MOCK_CONST_METHOD0(GetTargetFilePath, const base::FilePath&()); | 145 MOCK_CONST_METHOD0(GetTargetFilePath, const base::FilePath&()); |
145 MOCK_CONST_METHOD0(GetTargetDisposition, TargetDisposition()); | 146 MOCK_CONST_METHOD0(GetTargetDisposition, TargetDisposition()); |
146 MOCK_METHOD1(OnContentCheckCompleted, void(DownloadDangerType)); | 147 MOCK_METHOD2(OnContentCheckCompleted, void(DownloadDangerType, bool)); |
147 MOCK_CONST_METHOD0(GetState, DownloadState()); | 148 MOCK_CONST_METHOD0(GetState, DownloadState()); |
148 MOCK_CONST_METHOD0(GetUrlChain, const std::vector<GURL>&()); | 149 MOCK_CONST_METHOD0(GetUrlChain, const std::vector<GURL>&()); |
149 MOCK_METHOD1(SetTotalBytes, void(int64_t)); | 150 MOCK_METHOD1(SetTotalBytes, void(int64_t)); |
150 MOCK_CONST_METHOD0(GetURL, const GURL&()); | 151 MOCK_CONST_METHOD0(GetURL, const GURL&()); |
151 MOCK_CONST_METHOD0(GetOriginalUrl, const GURL&()); | 152 MOCK_CONST_METHOD0(GetOriginalUrl, const GURL&()); |
152 MOCK_CONST_METHOD0(GetReferrerUrl, const GURL&()); | 153 MOCK_CONST_METHOD0(GetReferrerUrl, const GURL&()); |
153 MOCK_CONST_METHOD0(GetTabUrl, const GURL&()); | 154 MOCK_CONST_METHOD0(GetTabUrl, const GURL&()); |
154 MOCK_CONST_METHOD0(GetTabReferrerUrl, const GURL&()); | 155 MOCK_CONST_METHOD0(GetTabReferrerUrl, const GURL&()); |
155 MOCK_CONST_METHOD0(GetSuggestedFilename, std::string()); | 156 MOCK_CONST_METHOD0(GetSuggestedFilename, std::string()); |
156 MOCK_CONST_METHOD0(GetContentDisposition, std::string()); | 157 MOCK_CONST_METHOD0(GetContentDisposition, std::string()); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 : public DownloadFileFactory, | 398 : public DownloadFileFactory, |
398 public base::SupportsWeakPtr<MockDownloadFileFactory> { | 399 public base::SupportsWeakPtr<MockDownloadFileFactory> { |
399 public: | 400 public: |
400 MockDownloadFileFactory() {} | 401 MockDownloadFileFactory() {} |
401 virtual ~MockDownloadFileFactory() {} | 402 virtual ~MockDownloadFileFactory() {} |
402 | 403 |
403 // Overridden method from DownloadFileFactory | 404 // Overridden method from DownloadFileFactory |
404 MOCK_METHOD2(MockCreateFile, | 405 MOCK_METHOD2(MockCreateFile, |
405 MockDownloadFile*(const DownloadSaveInfo&, ByteStreamReader*)); | 406 MockDownloadFile*(const DownloadSaveInfo&, ByteStreamReader*)); |
406 | 407 |
407 virtual DownloadFile* CreateFile( | 408 DownloadFile* CreateFile( |
408 std::unique_ptr<DownloadSaveInfo> save_info, | 409 std::unique_ptr<DownloadSaveInfo> save_info, |
409 const base::FilePath& default_download_directory, | 410 const base::FilePath& default_download_directory, |
410 std::unique_ptr<ByteStreamReader> byte_stream, | 411 std::unique_ptr<ByteStreamReader> byte_stream, |
411 const net::NetLogWithSource& net_log, | 412 const net::NetLogWithSource& net_log, |
412 base::WeakPtr<DownloadDestinationObserver> observer) override { | 413 base::WeakPtr<DownloadDestinationObserver> observer) override { |
413 return MockCreateFile(*save_info, byte_stream.get()); | 414 return MockCreateFile(*save_info, byte_stream.get()); |
414 } | 415 } |
415 }; | 416 }; |
416 | 417 |
417 class MockBrowserContext : public BrowserContext { | 418 class MockBrowserContext : public BrowserContext { |
(...skipping 14 matching lines...) Expand all Loading... |
432 MOCK_METHOD0(GetPushMessagingService, PushMessagingService*()); | 433 MOCK_METHOD0(GetPushMessagingService, PushMessagingService*()); |
433 MOCK_METHOD0(GetSSLHostStateDelegate, SSLHostStateDelegate*()); | 434 MOCK_METHOD0(GetSSLHostStateDelegate, SSLHostStateDelegate*()); |
434 MOCK_METHOD0(GetPermissionManager, PermissionManager*()); | 435 MOCK_METHOD0(GetPermissionManager, PermissionManager*()); |
435 MOCK_METHOD0(GetBackgroundSyncController, BackgroundSyncController*()); | 436 MOCK_METHOD0(GetBackgroundSyncController, BackgroundSyncController*()); |
436 MOCK_METHOD0(CreateMediaRequestContext, | 437 MOCK_METHOD0(CreateMediaRequestContext, |
437 net::URLRequestContextGetter*()); | 438 net::URLRequestContextGetter*()); |
438 MOCK_METHOD2(CreateMediaRequestContextForStoragePartition, | 439 MOCK_METHOD2(CreateMediaRequestContextForStoragePartition, |
439 net::URLRequestContextGetter*( | 440 net::URLRequestContextGetter*( |
440 const base::FilePath& partition_path, bool in_memory)); | 441 const base::FilePath& partition_path, bool in_memory)); |
441 | 442 |
442 // Define these two methods to avoid a | 443 // Define these two methods to avoid a cannot access private member declared |
443 // cannot access private member declared in class 'ScopedVector<net::URLReques
tInterceptor>' | 444 // in class 'ScopedVector<net::URLRequestInterceptor>' build error if they're |
444 // build error if they're put in MOCK_METHOD. | 445 // put in MOCK_METHOD. |
445 net::URLRequestContextGetter* CreateRequestContext( | 446 net::URLRequestContextGetter* CreateRequestContext( |
446 ProtocolHandlerMap* protocol_handlers, | 447 ProtocolHandlerMap* protocol_handlers, |
447 URLRequestInterceptorScopedVector request_interceptors) override { | 448 URLRequestInterceptorScopedVector request_interceptors) override { |
448 return nullptr; | 449 return nullptr; |
449 } | 450 } |
450 | 451 |
451 net::URLRequestContextGetter* CreateRequestContextForStoragePartition( | 452 net::URLRequestContextGetter* CreateRequestContextForStoragePartition( |
452 const base::FilePath& partition_path, | 453 const base::FilePath& partition_path, |
453 bool in_memory, | 454 bool in_memory, |
454 ProtocolHandlerMap* protocol_handlers, | 455 ProtocolHandlerMap* protocol_handlers, |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0); | 753 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0); |
753 | 754 |
754 base::Callback<bool(const GURL&)> url_filter = | 755 base::Callback<bool(const GURL&)> url_filter = |
755 GetSingleURLFilter(download_urls_[0]); | 756 GetSingleURLFilter(download_urls_[0]); |
756 int remove_count = download_manager_->RemoveDownloadsByURLAndTime( | 757 int remove_count = download_manager_->RemoveDownloadsByURLAndTime( |
757 url_filter, base::Time(), base::Time::Max()); | 758 url_filter, base::Time(), base::Time::Max()); |
758 EXPECT_EQ(remove_count, 1); | 759 EXPECT_EQ(remove_count, 1); |
759 } | 760 } |
760 | 761 |
761 } // namespace content | 762 } // namespace content |
OLD | NEW |