| 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 15 matching lines...) Expand all Loading... |
| 66 // Handle any delegate portions of a state change operation on the | 65 // Handle any delegate portions of a state change operation on the |
| 67 // DownloadItem. | 66 // DownloadItem. |
| 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 | 71 |
| 73 // Assert consistent state for delgate object at various transitions. | 72 // Assert consistent state for delgate object at various transitions. |
| 74 virtual void AssertStateConsistent(DownloadItem* download) const = 0; | 73 virtual void AssertStateConsistent(DownloadItem* download) const = 0; |
| 75 | 74 |
| 75 protected: |
| 76 virtual ~Delegate(); |
| 77 |
| 76 private: | 78 private: |
| 77 // For "Outlives attached DownloadItemImpl" invariant assertion. | 79 // For "Outlives attached DownloadItemImpl" invariant assertion. |
| 78 int count_; | 80 int count_; |
| 79 }; | 81 }; |
| 80 | 82 |
| 81 // Note that it is the responsibility of the caller to ensure that a | 83 // Note that it is the responsibility of the caller to ensure that a |
| 82 // DownloadItemImpl::Delegate passed to a DownloadItemImpl constructor | 84 // DownloadItemImpl::Delegate passed to a DownloadItemImpl constructor |
| 83 // outlives the DownloadItemImpl. | 85 // outlives the DownloadItemImpl. |
| 84 | 86 |
| 85 // Constructing from persistent store: | 87 // Constructing from persistent store: |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 // are owned by the DownloadItemImpl. | 393 // are owned by the DownloadItemImpl. |
| 392 std::map<const void*, ExternalData*> external_data_map_; | 394 std::map<const void*, ExternalData*> external_data_map_; |
| 393 | 395 |
| 394 // Net log to use for this download. | 396 // Net log to use for this download. |
| 395 const net::BoundNetLog bound_net_log_; | 397 const net::BoundNetLog bound_net_log_; |
| 396 | 398 |
| 397 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); | 399 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); |
| 398 }; | 400 }; |
| 399 | 401 |
| 400 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 402 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
| OLD | NEW |