| 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 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 void set_load_timing_info(const LoadTimingInfo& load_timing_info) { | 101 void set_load_timing_info(const LoadTimingInfo& load_timing_info) { |
| 102 load_timing_info_ = load_timing_info; | 102 load_timing_info_ = load_timing_info; |
| 103 } | 103 } |
| 104 | 104 |
| 105 RequestPriority priority() const { return priority_; } | 105 RequestPriority priority() const { return priority_; } |
| 106 | 106 |
| 107 // Create a protocol handler for callers that don't subclass. | 107 // Create a protocol handler for callers that don't subclass. |
| 108 static URLRequestJobFactory::ProtocolHandler* CreateProtocolHandler(); | 108 static URLRequestJobFactory::ProtocolHandler* CreateProtocolHandler(); |
| 109 | 109 |
| 110 // Job functions | 110 // Job functions |
| 111 virtual void SetPriority(RequestPriority priority) override; | 111 void SetPriority(RequestPriority priority) override; |
| 112 virtual void Start() override; | 112 void Start() override; |
| 113 virtual bool ReadRawData(IOBuffer* buf, | 113 bool ReadRawData(IOBuffer* buf, int buf_size, int* bytes_read) override; |
| 114 int buf_size, | 114 void Kill() override; |
| 115 int *bytes_read) override; | 115 bool GetMimeType(std::string* mime_type) const override; |
| 116 virtual void Kill() override; | 116 void GetResponseInfo(HttpResponseInfo* info) override; |
| 117 virtual bool GetMimeType(std::string* mime_type) const override; | 117 void GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override; |
| 118 virtual void GetResponseInfo(HttpResponseInfo* info) override; | 118 int GetResponseCode() const override; |
| 119 virtual void GetLoadTimingInfo( | 119 bool IsRedirectResponse(GURL* location, int* http_status_code) override; |
| 120 LoadTimingInfo* load_timing_info) const override; | |
| 121 virtual int GetResponseCode() const override; | |
| 122 virtual bool IsRedirectResponse(GURL* location, | |
| 123 int* http_status_code) override; | |
| 124 | 120 |
| 125 protected: | 121 protected: |
| 126 // Override to specify whether the next read done from this job will | 122 // Override to specify whether the next read done from this job will |
| 127 // return IO pending. This controls whether or not the WAITING state will | 123 // return IO pending. This controls whether or not the WAITING state will |
| 128 // transition back to WAITING or to DATA_AVAILABLE after an asynchronous | 124 // transition back to WAITING or to DATA_AVAILABLE after an asynchronous |
| 129 // read is processed. | 125 // read is processed. |
| 130 virtual bool NextReadAsync(); | 126 virtual bool NextReadAsync(); |
| 131 | 127 |
| 132 // This is what operation we are going to do next when this job is handled. | 128 // This is what operation we are going to do next when this job is handled. |
| 133 // When the stage is DONE, this job will not be put on the queue. | 129 // When the stage is DONE, this job will not be put on the queue. |
| 134 enum Stage { WAITING, DATA_AVAILABLE, ALL_DATA, DONE }; | 130 enum Stage { WAITING, DATA_AVAILABLE, ALL_DATA, DONE }; |
| 135 | 131 |
| 136 virtual ~URLRequestTestJob(); | 132 ~URLRequestTestJob() override; |
| 137 | 133 |
| 138 // Call to process the next opeation, usually sending a notification, and | 134 // Call to process the next opeation, usually sending a notification, and |
| 139 // advancing the stage if necessary. THIS MAY DELETE THE OBJECT. | 135 // advancing the stage if necessary. THIS MAY DELETE THE OBJECT. |
| 140 void ProcessNextOperation(); | 136 void ProcessNextOperation(); |
| 141 | 137 |
| 142 // Call to move the job along to the next operation. | 138 // Call to move the job along to the next operation. |
| 143 void AdvanceJob(); | 139 void AdvanceJob(); |
| 144 | 140 |
| 145 // Called via InvokeLater to cause callbacks to occur after Start() returns. | 141 // Called via InvokeLater to cause callbacks to occur after Start() returns. |
| 146 virtual void StartAsync(); | 142 virtual void StartAsync(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 167 int async_buf_size_; | 163 int async_buf_size_; |
| 168 | 164 |
| 169 LoadTimingInfo load_timing_info_; | 165 LoadTimingInfo load_timing_info_; |
| 170 | 166 |
| 171 base::WeakPtrFactory<URLRequestTestJob> weak_factory_; | 167 base::WeakPtrFactory<URLRequestTestJob> weak_factory_; |
| 172 }; | 168 }; |
| 173 | 169 |
| 174 } // namespace net | 170 } // namespace net |
| 175 | 171 |
| 176 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ | 172 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ |
| OLD | NEW |