Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1627)

Side by Side Diff: mojo/services/network/url_loader_impl.h

Issue 649783002: Add mojo <--> net IO adapters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/services/network/net_adapters.cc ('k') | mojo/services/network/url_loader_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common/handle_watcher.h" 10 #include "mojo/common/handle_watcher.h"
11 #include "mojo/public/cpp/bindings/interface_impl.h" 11 #include "mojo/public/cpp/bindings/interface_impl.h"
12 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" 12 #include "mojo/services/public/interfaces/network/url_loader.mojom.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/url_request/url_request.h" 14 #include "net/url_request/url_request.h"
15 15
16 namespace mojo { 16 namespace mojo {
17
17 class NetworkContext; 18 class NetworkContext;
19 class NetToMojoPendingBuffer;
18 20
19 class URLLoaderImpl : public InterfaceImpl<URLLoader>, 21 class URLLoaderImpl : public InterfaceImpl<URLLoader>,
20 public net::URLRequest::Delegate { 22 public net::URLRequest::Delegate {
21 public: 23 public:
22 explicit URLLoaderImpl(NetworkContext* context); 24 explicit URLLoaderImpl(NetworkContext* context);
23 virtual ~URLLoaderImpl(); 25 virtual ~URLLoaderImpl();
24 26
25 private: 27 private:
26 class PendingWriteToDataPipe;
27 class DependentIOBuffer;
28
29 // URLLoader methods: 28 // URLLoader methods:
30 virtual void Start( 29 virtual void Start(
31 URLRequestPtr request, 30 URLRequestPtr request,
32 const Callback<void(URLResponsePtr)>& callback) override; 31 const Callback<void(URLResponsePtr)>& callback) override;
33 virtual void FollowRedirect( 32 virtual void FollowRedirect(
34 const Callback<void(URLResponsePtr)>& callback) override; 33 const Callback<void(URLResponsePtr)>& callback) override;
35 virtual void QueryStatus( 34 virtual void QueryStatus(
36 const Callback<void(URLLoaderStatusPtr)>& callback) override; 35 const Callback<void(URLLoaderStatusPtr)>& callback) override;
37 36
38 // net::URLRequest::Delegate methods: 37 // net::URLRequest::Delegate methods:
39 virtual void OnReceivedRedirect(net::URLRequest* url_request, 38 virtual void OnReceivedRedirect(net::URLRequest* url_request,
40 const net::RedirectInfo& redirect_info, 39 const net::RedirectInfo& redirect_info,
41 bool* defer_redirect) override; 40 bool* defer_redirect) override;
42 virtual void OnResponseStarted(net::URLRequest* url_request) override; 41 virtual void OnResponseStarted(net::URLRequest* url_request) override;
43 virtual void OnReadCompleted(net::URLRequest* url_request, int bytes_read) 42 virtual void OnReadCompleted(net::URLRequest* url_request, int bytes_read)
44 override; 43 override;
45 44
46 void SendError( 45 void SendError(
47 int error, 46 int error,
48 const Callback<void(URLResponsePtr)>& callback); 47 const Callback<void(URLResponsePtr)>& callback);
49 void SendResponse(URLResponsePtr response); 48 void SendResponse(URLResponsePtr response);
50 void OnResponseBodyStreamReady(MojoResult result); 49 void OnResponseBodyStreamReady(MojoResult result);
51 void WaitToReadMore();
52 void ReadMore(); 50 void ReadMore();
53 void DidRead(uint32_t num_bytes, bool completed_synchronously); 51 void DidRead(uint32_t num_bytes, bool completed_synchronously);
54 52
55 NetworkContext* context_; 53 NetworkContext* context_;
56 scoped_ptr<net::URLRequest> url_request_; 54 scoped_ptr<net::URLRequest> url_request_;
57 Callback<void(URLResponsePtr)> callback_; 55 Callback<void(URLResponsePtr)> callback_;
58 ScopedDataPipeProducerHandle response_body_stream_; 56 ScopedDataPipeProducerHandle response_body_stream_;
59 scoped_refptr<PendingWriteToDataPipe> pending_write_; 57 scoped_refptr<NetToMojoPendingBuffer> pending_write_;
60 common::HandleWatcher handle_watcher_; 58 common::HandleWatcher handle_watcher_;
61 uint32 response_body_buffer_size_; 59 uint32 response_body_buffer_size_;
62 bool auto_follow_redirects_; 60 bool auto_follow_redirects_;
63 61
64 base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_; 62 base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_;
65 }; 63 };
66 64
67 } // namespace mojo 65 } // namespace mojo
68 66
69 #endif // MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_ 67 #endif // MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_
OLDNEW
« no previous file with comments | « mojo/services/network/net_adapters.cc ('k') | mojo/services/network/url_loader_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698