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_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ |
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // static | 42 // static |
43 // This function is passed into ResourceDispatcherHostImpl during its | 43 // This function is passed into ResourceDispatcherHostImpl during its |
44 // creation and is used to create instances of DownloadResourceHandler as | 44 // creation and is used to create instances of DownloadResourceHandler as |
45 // needed. | 45 // needed. |
46 // TODO(ananta) | 46 // TODO(ananta) |
47 // Find a better way to achieve this. Ideally we want to move the logic of | 47 // Find a better way to achieve this. Ideally we want to move the logic of |
48 // creating DownloadResourceHandler instances out of | 48 // creating DownloadResourceHandler instances out of |
49 // ResourceDispatcherHostImpl. | 49 // ResourceDispatcherHostImpl. |
50 static std::unique_ptr<ResourceHandler> Create(net::URLRequest* request); | 50 static std::unique_ptr<ResourceHandler> Create(net::URLRequest* request); |
51 | 51 |
52 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, | 52 void OnRequestRedirected( |
53 ResourceResponse* response, | 53 const net::RedirectInfo& redirect_info, |
54 bool* defer) override; | 54 ResourceResponse* response, |
| 55 std::unique_ptr<ResourceController> controller) override; |
55 | 56 |
56 // Send the download creation information to the download thread. | 57 // Send the download creation information to the download thread. |
57 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; | 58 void OnResponseStarted( |
| 59 ResourceResponse* response, |
| 60 std::unique_ptr<ResourceController> controller) override; |
58 | 61 |
59 // Pass-through implementation. | 62 // Pass-through implementation. |
60 bool OnWillStart(const GURL& url, bool* defer) override; | 63 void OnWillStart(const GURL& url, |
| 64 std::unique_ptr<ResourceController> controller) override; |
61 | 65 |
62 // Create a new buffer, which will be handed to the download thread for file | 66 // Create a new buffer, which will be handed to the download thread for file |
63 // writing and deletion. | 67 // writing and deletion. |
64 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 68 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
65 int* buf_size, | 69 int* buf_size, |
66 int min_size) override; | 70 int min_size) override; |
67 | 71 |
68 bool OnReadCompleted(int bytes_read, bool* defer) override; | 72 void OnReadCompleted(int bytes_read, |
| 73 std::unique_ptr<ResourceController> controller) override; |
69 | 74 |
70 void OnResponseCompleted(const net::URLRequestStatus& status, | 75 void OnResponseCompleted( |
71 bool* defer) override; | 76 const net::URLRequestStatus& status, |
| 77 std::unique_ptr<ResourceController> controller) override; |
72 | 78 |
73 // N/A to this flavor of DownloadHandler. | 79 // N/A to this flavor of DownloadHandler. |
74 void OnDataDownloaded(int bytes_downloaded) override; | 80 void OnDataDownloaded(int bytes_downloaded) override; |
75 | 81 |
76 void PauseRequest(); | 82 void PauseRequest(); |
77 void ResumeRequest(); | 83 void ResumeRequest(); |
78 | 84 |
79 // May result in this object being deleted by its owner. | 85 // May result in this object being deleted by its owner. |
80 void CancelRequest(); | 86 void CancelRequest(); |
81 | 87 |
(...skipping 11 matching lines...) Expand all Loading... |
93 | 99 |
94 // Stores information about the download that must be acquired on the UI | 100 // Stores information about the download that must be acquired on the UI |
95 // thread before StartOnUIThread is called. | 101 // thread before StartOnUIThread is called. |
96 // Created on IO thread, but only accessed on UI thread. |tab_info_| holds | 102 // Created on IO thread, but only accessed on UI thread. |tab_info_| holds |
97 // the pointer until we pass it off to StartOnUIThread or DeleteSoon. | 103 // the pointer until we pass it off to StartOnUIThread or DeleteSoon. |
98 // Marked as a std::unique_ptr<> to indicate ownership of the structure, but | 104 // Marked as a std::unique_ptr<> to indicate ownership of the structure, but |
99 // deletion must occur on the IO thread. | 105 // deletion must occur on the IO thread. |
100 std::unique_ptr<DownloadTabInfo> tab_info_; | 106 std::unique_ptr<DownloadTabInfo> tab_info_; |
101 | 107 |
102 DownloadRequestCore core_; | 108 DownloadRequestCore core_; |
| 109 |
103 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); | 110 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); |
104 }; | 111 }; |
105 | 112 |
106 } // namespace content | 113 } // namespace content |
107 | 114 |
108 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ | 115 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ |
OLD | NEW |