| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 HEADLESS_PUBLIC_UTIL_IN_MEMORY_URL_REQUEST_JOB_H_ | 5 #ifndef HEADLESS_PUBLIC_UTIL_IN_MEMORY_URL_REQUEST_JOB_H_ |
| 6 #define HEADLESS_PUBLIC_UTIL_IN_MEMORY_URL_REQUEST_JOB_H_ | 6 #define HEADLESS_PUBLIC_UTIL_IN_MEMORY_URL_REQUEST_JOB_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "headless/public/util/in_memory_protocol_handler.h" | 9 #include "headless/public/util/in_memory_protocol_handler.h" |
| 10 #include "net/url_request/url_request_job.h" | 10 #include "net/url_request/url_request_job.h" |
| 11 | 11 |
| 12 namespace net { | |
| 13 class StringIOBuffer; | |
| 14 class DrainableIOBuffer; | |
| 15 } | |
| 16 | |
| 17 namespace headless { | 12 namespace headless { |
| 18 class InMemoryRequestJob : public net::URLRequestJob { | 13 class InMemoryRequestJob : public net::URLRequestJob { |
| 19 public: | 14 public: |
| 20 InMemoryRequestJob(net::URLRequest* request, | 15 InMemoryRequestJob(net::URLRequest* request, |
| 21 net::NetworkDelegate* network_delegate, | 16 net::NetworkDelegate* network_delegate, |
| 22 const InMemoryProtocolHandler::Response* response); | 17 const InMemoryProtocolHandler::Response* response); |
| 23 | 18 |
| 24 // net::URLRequestJob implementation: | 19 // net::URLRequestJob implementation: |
| 25 void Start() override; | 20 void Start() override; |
| 26 void Kill() override; | 21 void Kill() override; |
| 27 int ReadRawData(net::IOBuffer* buf, int buf_size) override; | 22 int ReadRawData(net::IOBuffer* buf, int buf_size) override; |
| 28 bool GetMimeType(std::string* mime_type) const override; | 23 bool GetMimeType(std::string* mime_type) const override; |
| 29 | 24 |
| 30 private: | 25 private: |
| 31 ~InMemoryRequestJob() override; | 26 ~InMemoryRequestJob() override; |
| 32 | 27 |
| 33 void StartAsync(); | 28 void StartAsync(); |
| 34 | 29 |
| 35 const InMemoryProtocolHandler::Response* response_; // NOT OWNED | 30 const InMemoryProtocolHandler::Response* response_; // NOT OWNED |
| 36 size_t data_offset_; | 31 size_t data_offset_; |
| 37 | 32 |
| 38 base::WeakPtrFactory<InMemoryRequestJob> weak_factory_; | 33 base::WeakPtrFactory<InMemoryRequestJob> weak_factory_; |
| 39 | 34 |
| 40 DISALLOW_COPY_AND_ASSIGN(InMemoryRequestJob); | 35 DISALLOW_COPY_AND_ASSIGN(InMemoryRequestJob); |
| 41 }; | 36 }; |
| 42 | 37 |
| 43 } // namespace headless | 38 } // namespace headless |
| 44 | 39 |
| 45 #endif // HEADLESS_PUBLIC_UTIL_IN_MEMORY_URL_REQUEST_JOB_H_ | 40 #endif // HEADLESS_PUBLIC_UTIL_IN_MEMORY_URL_REQUEST_JOB_H_ |
| OLD | NEW |