OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 NET_URL_REQUEST_URL_REQUEST_INET_JOB_H__ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_INET_JOB_H__ |
6 #define NET_URL_REQUEST_URL_REQUEST_INET_JOB_H__ | 6 #define NET_URL_REQUEST_URL_REQUEST_INET_JOB_H__ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <wininet.h> | 9 #include <wininet.h> |
10 | 10 |
11 #include "base/lock.h" | 11 #include "base/lock.h" |
12 #include "net/url_request/url_request.h" | 12 #include "net/url_request/url_request.h" |
13 #include "net/url_request/url_request_job.h" | 13 #include "net/url_request/url_request_job.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 class AuthData; | 16 class AuthData; |
17 } | 17 } |
18 | 18 |
19 class MessageLoop; | 19 class MessageLoop; |
20 | 20 |
21 // For all WinInet-based URL requests | 21 // For all WinInet-based URL requests |
22 class URLRequestInetJob : public URLRequestJob { | 22 class URLRequestInetJob : public URLRequestJob { |
23 public: | 23 public: |
24 URLRequestInetJob(URLRequest* request); | 24 URLRequestInetJob(URLRequest* request); |
25 virtual ~URLRequestInetJob(); | |
26 | 25 |
27 virtual void SetExtraRequestHeaders(const std::string& headers) { | 26 virtual void SetExtraRequestHeaders(const std::string& headers) { |
28 extra_request_headers_ = headers; | 27 extra_request_headers_ = headers; |
29 } | 28 } |
30 | 29 |
31 virtual void Kill(); | 30 virtual void Kill(); |
32 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); | 31 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); |
33 | 32 |
34 // URLRequestJob Authentication methods | 33 // URLRequestJob Authentication methods |
35 virtual void SetAuth(const std::wstring& username, | 34 virtual void SetAuth(const std::wstring& username, |
(...skipping 14 matching lines...) Expand all Loading... |
50 // does not it must call the base class' OnIOComplete. | 49 // does not it must call the base class' OnIOComplete. |
51 virtual void OnIOComplete(const AsyncResult& result) = 0; | 50 virtual void OnIOComplete(const AsyncResult& result) = 0; |
52 | 51 |
53 // Used internally to setup the OnIOComplete call. Public because this | 52 // Used internally to setup the OnIOComplete call. Public because this |
54 // is called from the Windows procedure, and we don't want to make it a | 53 // is called from the Windows procedure, and we don't want to make it a |
55 // friend so we can avoid the Windows headers for this header file. | 54 // friend so we can avoid the Windows headers for this header file. |
56 void CallOnIOComplete(const AsyncResult& result); | 55 void CallOnIOComplete(const AsyncResult& result); |
57 | 56 |
58 HINTERNET request_handle() const { return request_handle_; } | 57 HINTERNET request_handle() const { return request_handle_; } |
59 | 58 |
60 protected: | 59 protected: |
| 60 virtual ~URLRequestInetJob(); |
| 61 |
61 // Called by this class and subclasses to send or resend this request. | 62 // Called by this class and subclasses to send or resend this request. |
62 virtual void SendRequest() = 0; | 63 virtual void SendRequest() = 0; |
63 | 64 |
64 // Calls InternetReadFile(Ex) depending on the derived class. | 65 // Calls InternetReadFile(Ex) depending on the derived class. |
65 // Returns ERROR_SUCCESS on success, or else a standard Windows error code | 66 // Returns ERROR_SUCCESS on success, or else a standard Windows error code |
66 // on failure (from GetLastError()). | 67 // on failure (from GetLastError()). |
67 virtual int CallInternetRead(char* dest, int dest_size, int *bytes_read) = 0; | 68 virtual int CallInternetRead(char* dest, int dest_size, int *bytes_read) = 0; |
68 | 69 |
69 // After the base class calls CallInternetRead and the result is available, | 70 // After the base class calls CallInternetRead and the result is available, |
70 // it will call this method to get the number of received bytes. | 71 // it will call this method to get the number of received bytes. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // can reuse the async_result_ member for all its asynchronous IOs. | 153 // can reuse the async_result_ member for all its asynchronous IOs. |
153 AsyncResult async_result_; | 154 AsyncResult async_result_; |
154 | 155 |
155 Lock loop_lock_; | 156 Lock loop_lock_; |
156 MessageLoop* loop_; | 157 MessageLoop* loop_; |
157 | 158 |
158 DISALLOW_EVIL_CONSTRUCTORS(URLRequestInetJob); | 159 DISALLOW_EVIL_CONSTRUCTORS(URLRequestInetJob); |
159 }; | 160 }; |
160 | 161 |
161 #endif // NET_URL_REQUEST_URL_REQUEST_INET_JOB_H__ | 162 #endif // NET_URL_REQUEST_URL_REQUEST_INET_JOB_H__ |
OLD | NEW |