Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_ | 5 #ifndef MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_ |
| 6 #define MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_ | 6 #define MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
|
viettrungluu
2014/10/06 16:12:20
Please remove this include.
Mostyn Bramley-Moore
2014/10/06 17:13:34
Done.
| |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "mojo/common/handle_watcher.h" | 11 #include "mojo/common/handle_watcher.h" |
| 12 #include "mojo/public/cpp/bindings/interface_impl.h" | 12 #include "mojo/public/cpp/bindings/interface_impl.h" |
| 13 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" | 13 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 #include "net/url_request/url_request.h" | 15 #include "net/url_request/url_request.h" |
| 16 | 16 |
| 17 namespace mojo { | 17 namespace mojo { |
| 18 class NetworkContext; | 18 class NetworkContext; |
| 19 | 19 |
| 20 class URLLoaderImpl : public InterfaceImpl<URLLoader>, | 20 class URLLoaderImpl : public InterfaceImpl<URLLoader>, |
| 21 public net::URLRequest::Delegate { | 21 public net::URLRequest::Delegate { |
| 22 public: | 22 public: |
| 23 explicit URLLoaderImpl(NetworkContext* context); | 23 explicit URLLoaderImpl(NetworkContext* context); |
| 24 virtual ~URLLoaderImpl(); | 24 virtual ~URLLoaderImpl(); |
| 25 | 25 |
| 26 private: | 26 private: |
| 27 class PendingWriteToDataPipe; | 27 class PendingWriteToDataPipe; |
| 28 class DependentIOBuffer; | 28 class DependentIOBuffer; |
| 29 | 29 |
| 30 // URLLoader methods: | 30 // URLLoader methods: |
| 31 virtual void Start( | 31 virtual void Start( |
| 32 URLRequestPtr request, | 32 URLRequestPtr request, |
| 33 const Callback<void(URLResponsePtr)>& callback) OVERRIDE; | 33 const Callback<void(URLResponsePtr)>& callback) override; |
| 34 virtual void FollowRedirect( | 34 virtual void FollowRedirect( |
| 35 const Callback<void(URLResponsePtr)>& callback) OVERRIDE; | 35 const Callback<void(URLResponsePtr)>& callback) override; |
| 36 virtual void QueryStatus( | 36 virtual void QueryStatus( |
| 37 const Callback<void(URLLoaderStatusPtr)>& callback) OVERRIDE; | 37 const Callback<void(URLLoaderStatusPtr)>& callback) override; |
| 38 | 38 |
| 39 // net::URLRequest::Delegate methods: | 39 // net::URLRequest::Delegate methods: |
| 40 virtual void OnReceivedRedirect(net::URLRequest* url_request, | 40 virtual void OnReceivedRedirect(net::URLRequest* url_request, |
| 41 const net::RedirectInfo& redirect_info, | 41 const net::RedirectInfo& redirect_info, |
| 42 bool* defer_redirect) OVERRIDE; | 42 bool* defer_redirect) override; |
| 43 virtual void OnResponseStarted(net::URLRequest* url_request) OVERRIDE; | 43 virtual void OnResponseStarted(net::URLRequest* url_request) override; |
| 44 virtual void OnReadCompleted(net::URLRequest* url_request, int bytes_read) | 44 virtual void OnReadCompleted(net::URLRequest* url_request, int bytes_read) |
| 45 OVERRIDE; | 45 override; |
| 46 | 46 |
| 47 void SendError( | 47 void SendError( |
| 48 int error, | 48 int error, |
| 49 const Callback<void(URLResponsePtr)>& callback); | 49 const Callback<void(URLResponsePtr)>& callback); |
| 50 void SendResponse(URLResponsePtr response); | 50 void SendResponse(URLResponsePtr response); |
| 51 void OnResponseBodyStreamReady(MojoResult result); | 51 void OnResponseBodyStreamReady(MojoResult result); |
| 52 void WaitToReadMore(); | 52 void WaitToReadMore(); |
| 53 void ReadMore(); | 53 void ReadMore(); |
| 54 void DidRead(uint32_t num_bytes, bool completed_synchronously); | 54 void DidRead(uint32_t num_bytes, bool completed_synchronously); |
| 55 | 55 |
| 56 NetworkContext* context_; | 56 NetworkContext* context_; |
| 57 scoped_ptr<net::URLRequest> url_request_; | 57 scoped_ptr<net::URLRequest> url_request_; |
| 58 Callback<void(URLResponsePtr)> callback_; | 58 Callback<void(URLResponsePtr)> callback_; |
| 59 ScopedDataPipeProducerHandle response_body_stream_; | 59 ScopedDataPipeProducerHandle response_body_stream_; |
| 60 scoped_refptr<PendingWriteToDataPipe> pending_write_; | 60 scoped_refptr<PendingWriteToDataPipe> pending_write_; |
| 61 common::HandleWatcher handle_watcher_; | 61 common::HandleWatcher handle_watcher_; |
| 62 uint32 response_body_buffer_size_; | 62 uint32 response_body_buffer_size_; |
| 63 bool auto_follow_redirects_; | 63 bool auto_follow_redirects_; |
| 64 | 64 |
| 65 base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_; | 65 base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 } // namespace mojo | 68 } // namespace mojo |
| 69 | 69 |
| 70 #endif // MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_ | 70 #endif // MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_ |
| OLD | NEW |