| 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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "mojo/application/app_lifetime_helper.h" |
| 10 #include "mojo/common/handle_watcher.h" | 11 #include "mojo/common/handle_watcher.h" |
| 11 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | 12 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" |
| 12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 13 #include "net/url_request/url_request.h" | 14 #include "net/url_request/url_request.h" |
| 14 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" | 15 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
| 15 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h" | 16 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h" |
| 16 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h" | 17 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h" |
| 17 | 18 |
| 18 namespace mojo { | 19 namespace mojo { |
| 19 | 20 |
| 20 class NetworkContext; | 21 class NetworkContext; |
| 21 class NetToMojoPendingBuffer; | 22 class NetToMojoPendingBuffer; |
| 22 | 23 |
| 23 class URLLoaderImpl : public URLLoader, | 24 class URLLoaderImpl : public URLLoader, |
| 24 public ErrorHandler, | 25 public ErrorHandler, |
| 25 public net::URLRequest::Delegate { | 26 public net::URLRequest::Delegate { |
| 26 public: | 27 public: |
| 27 URLLoaderImpl(NetworkContext* context, InterfaceRequest<URLLoader> request); | 28 URLLoaderImpl(NetworkContext* context, |
| 29 InterfaceRequest<URLLoader> request, |
| 30 scoped_ptr<mojo::AppRefCount> app_refcount); |
| 28 ~URLLoaderImpl() override; | 31 ~URLLoaderImpl() override; |
| 29 | 32 |
| 30 // Called when the associated NetworkContext is going away. | 33 // Called when the associated NetworkContext is going away. |
| 31 void Cleanup(); | 34 void Cleanup(); |
| 32 | 35 |
| 33 private: | 36 private: |
| 34 // URLLoader methods: | 37 // URLLoader methods: |
| 35 void Start(URLRequestPtr request, | 38 void Start(URLRequestPtr request, |
| 36 const Callback<void(URLResponsePtr)>& callback) override; | 39 const Callback<void(URLResponsePtr)>& callback) override; |
| 37 void FollowRedirect(const Callback<void(URLResponsePtr)>& callback) override; | 40 void FollowRedirect(const Callback<void(URLResponsePtr)>& callback) override; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 61 NetworkContext* context_; | 64 NetworkContext* context_; |
| 62 scoped_ptr<net::URLRequest> url_request_; | 65 scoped_ptr<net::URLRequest> url_request_; |
| 63 Callback<void(URLResponsePtr)> callback_; | 66 Callback<void(URLResponsePtr)> callback_; |
| 64 ScopedDataPipeProducerHandle response_body_stream_; | 67 ScopedDataPipeProducerHandle response_body_stream_; |
| 65 scoped_refptr<NetToMojoPendingBuffer> pending_write_; | 68 scoped_refptr<NetToMojoPendingBuffer> pending_write_; |
| 66 common::HandleWatcher handle_watcher_; | 69 common::HandleWatcher handle_watcher_; |
| 67 uint32 response_body_buffer_size_; | 70 uint32 response_body_buffer_size_; |
| 68 bool auto_follow_redirects_; | 71 bool auto_follow_redirects_; |
| 69 bool connected_; | 72 bool connected_; |
| 70 Binding<URLLoader> binding_; | 73 Binding<URLLoader> binding_; |
| 74 scoped_ptr<mojo::AppRefCount> app_refcount_; |
| 71 | 75 |
| 72 base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_; | 76 base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_; |
| 73 }; | 77 }; |
| 74 | 78 |
| 75 } // namespace mojo | 79 } // namespace mojo |
| 76 | 80 |
| 77 #endif // MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_ | 81 #endif // MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_ |
| OLD | NEW |