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_TEST_JOB_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ |
6 #define NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ |
7 | 7 |
8 #include "net/url_request/url_request.h" | 8 #include "net/url_request/url_request.h" |
9 #include "net/url_request/url_request_job.h" | 9 #include "net/url_request/url_request_job.h" |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // Processes one pending message from the stack, returning true if any | 44 // Processes one pending message from the stack, returning true if any |
45 // message was processed, or false if there are no more pending request | 45 // message was processed, or false if there are no more pending request |
46 // notifications to send. | 46 // notifications to send. |
47 static bool ProcessOnePendingMessage(); | 47 static bool ProcessOnePendingMessage(); |
48 | 48 |
49 // Factory method for protocol factory registration if callers don't subclass | 49 // Factory method for protocol factory registration if callers don't subclass |
50 static URLRequest::ProtocolFactory Factory; | 50 static URLRequest::ProtocolFactory Factory; |
51 | 51 |
52 // Job functions | 52 // Job functions |
53 virtual void Start(); | 53 virtual void Start(); |
54 virtual bool ReadRawData(char* buf, int buf_size, int *bytes_read); | 54 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); |
55 virtual void Kill(); | 55 virtual void Kill(); |
56 virtual bool GetMimeType(std::string* mime_type); | 56 virtual bool GetMimeType(std::string* mime_type); |
57 virtual void GetResponseInfo(net::HttpResponseInfo* info); | 57 virtual void GetResponseInfo(net::HttpResponseInfo* info); |
58 | 58 |
59 protected: | 59 protected: |
60 // This is what operation we are going to do next when this job is handled. | 60 // This is what operation we are going to do next when this job is handled. |
61 // When the stage is DONE, this job will not be put on the queue. | 61 // When the stage is DONE, this job will not be put on the queue. |
62 enum Stage { WAITING, DATA_AVAILABLE, ALL_DATA, DONE }; | 62 enum Stage { WAITING, DATA_AVAILABLE, ALL_DATA, DONE }; |
63 | 63 |
64 // Call to process the next opeation, usually sending a notification, and | 64 // Call to process the next opeation, usually sending a notification, and |
65 // advancing the stage if necessary. THIS MAY DELETE THE OBJECT, we will | 65 // advancing the stage if necessary. THIS MAY DELETE THE OBJECT, we will |
66 // return false if the operations are complete, true if there are more. | 66 // return false if the operations are complete, true if there are more. |
67 bool ProcessNextOperation(); | 67 bool ProcessNextOperation(); |
68 | 68 |
69 // Called via InvokeLater to cause callbacks to occur after Start() returns. | 69 // Called via InvokeLater to cause callbacks to occur after Start() returns. |
70 void StartAsync(); | 70 void StartAsync(); |
71 | 71 |
72 Stage stage_; | 72 Stage stage_; |
73 | 73 |
74 // The data to send, will be set in Start() | 74 // The data to send, will be set in Start() |
75 std::string data_; | 75 std::string data_; |
76 | 76 |
77 // current offset within data_ | 77 // current offset within data_ |
78 int offset_; | 78 int offset_; |
79 | 79 |
80 // Holds the buffer for an asynchronous ReadRawData call | 80 // Holds the buffer for an asynchronous ReadRawData call |
81 char* async_buf_; | 81 net::IOBuffer* async_buf_; |
82 int async_buf_size_; | 82 int async_buf_size_; |
83 }; | 83 }; |
84 | 84 |
85 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ | 85 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ |
86 | 86 |
OLD | NEW |