| 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 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // Delegate is defined in DownloadItemImpl (rather than DownloadItem) | 30 // Delegate is defined in DownloadItemImpl (rather than DownloadItem) |
| 31 // as it's relevant to the class implementation (class methods need to | 31 // as it's relevant to the class implementation (class methods need to |
| 32 // call into it) and doesn't have anything to do with its interface. | 32 // call into it) and doesn't have anything to do with its interface. |
| 33 // Despite this, the delegate methods take DownloadItems as arguments | 33 // Despite this, the delegate methods take DownloadItems as arguments |
| 34 // (rather than DownloadItemImpls) so that classes that inherit from it | 34 // (rather than DownloadItemImpls) so that classes that inherit from it |
| 35 // can be used with DownloadItem mocks rather than being tied to | 35 // can be used with DownloadItem mocks rather than being tied to |
| 36 // DownloadItemImpls. | 36 // DownloadItemImpls. |
| 37 class CONTENT_EXPORT Delegate { | 37 class CONTENT_EXPORT Delegate { |
| 38 public: | 38 public: |
| 39 Delegate(); | 39 Delegate(); |
| 40 virtual ~Delegate(); | |
| 41 | 40 |
| 42 // Used for catching use-after-free errors. | 41 // Used for catching use-after-free errors. |
| 43 void Attach(); | 42 void Attach(); |
| 44 void Detach(); | 43 void Detach(); |
| 45 | 44 |
| 46 // Tests if a file type should be opened automatically. | 45 // Tests if a file type should be opened automatically. |
| 47 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) = 0; | 46 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) = 0; |
| 48 | 47 |
| 49 // Allows the delegate to override the opening of a download. If it returns | 48 // Allows the delegate to override the opening of a download. If it returns |
| 50 // true then it's reponsible for opening the item. | 49 // true then it's reponsible for opening the item. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 68 virtual void DownloadCancelled(DownloadItem* download) = 0; | 67 virtual void DownloadCancelled(DownloadItem* download) = 0; |
| 69 virtual void DownloadCompleted(DownloadItem* download) = 0; | 68 virtual void DownloadCompleted(DownloadItem* download) = 0; |
| 70 virtual void DownloadOpened(DownloadItem* download) = 0; | 69 virtual void DownloadOpened(DownloadItem* download) = 0; |
| 71 virtual void DownloadRemoved(DownloadItem* download) = 0; | 70 virtual void DownloadRemoved(DownloadItem* download) = 0; |
| 72 virtual void DownloadRenamedToIntermediateName(DownloadItem* download) = 0; | 71 virtual void DownloadRenamedToIntermediateName(DownloadItem* download) = 0; |
| 73 virtual void DownloadRenamedToFinalName(DownloadItem* download) = 0; | 72 virtual void DownloadRenamedToFinalName(DownloadItem* download) = 0; |
| 74 | 73 |
| 75 // Assert consistent state for delgate object at various transitions. | 74 // Assert consistent state for delgate object at various transitions. |
| 76 virtual void AssertStateConsistent(DownloadItem* download) const = 0; | 75 virtual void AssertStateConsistent(DownloadItem* download) const = 0; |
| 77 | 76 |
| 77 protected: |
| 78 virtual ~Delegate(); |
| 79 |
| 78 private: | 80 private: |
| 79 // For "Outlives attached DownloadItemImpl" invariant assertion. | 81 // For "Outlives attached DownloadItemImpl" invariant assertion. |
| 80 int count_; | 82 int count_; |
| 81 }; | 83 }; |
| 82 | 84 |
| 83 // Note that it is the responsibility of the caller to ensure that a | 85 // Note that it is the responsibility of the caller to ensure that a |
| 84 // DownloadItemImpl::Delegate passed to a DownloadItemImpl constructor | 86 // DownloadItemImpl::Delegate passed to a DownloadItemImpl constructor |
| 85 // outlives the DownloadItemImpl. | 87 // outlives the DownloadItemImpl. |
| 86 | 88 |
| 87 // Constructing from persistent store: | 89 // Constructing from persistent store: |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 | 431 |
| 430 // Net log to use for this download. | 432 // Net log to use for this download. |
| 431 const net::BoundNetLog bound_net_log_; | 433 const net::BoundNetLog bound_net_log_; |
| 432 | 434 |
| 433 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; | 435 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; |
| 434 | 436 |
| 435 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); | 437 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); |
| 436 }; | 438 }; |
| 437 | 439 |
| 438 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 440 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
| OLD | NEW |