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

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

Issue 858093002: Update the network service from the Mojo repo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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/udp_socket_apptest.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/binding.h"
12 #include "mojo/public/cpp/bindings/error_handler.h"
11 #include "mojo/public/cpp/bindings/interface_impl.h" 13 #include "mojo/public/cpp/bindings/interface_impl.h"
12 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" 14 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
13 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
14 #include "net/url_request/url_request.h" 16 #include "net/url_request/url_request.h"
15 17
16 namespace mojo { 18 namespace mojo {
17 19
18 class NetworkContext; 20 class NetworkContext;
19 class NetToMojoPendingBuffer; 21 class NetToMojoPendingBuffer;
20 22
21 class URLLoaderImpl : public InterfaceImpl<URLLoader>, 23 class URLLoaderImpl : public URLLoader,
24 public ErrorHandler,
22 public net::URLRequest::Delegate { 25 public net::URLRequest::Delegate {
23 public: 26 public:
24 explicit URLLoaderImpl(NetworkContext* context); 27 URLLoaderImpl(NetworkContext* context, InterfaceRequest<URLLoader> request);
25 ~URLLoaderImpl() override; 28 ~URLLoaderImpl();
26 29
27 private: 30 private:
28 // URLLoader methods: 31 // URLLoader methods:
29 void Start(URLRequestPtr request, 32 void Start(URLRequestPtr request,
30 const Callback<void(URLResponsePtr)>& callback) override; 33 const Callback<void(URLResponsePtr)>& callback) override;
31 void FollowRedirect(const Callback<void(URLResponsePtr)>& callback) override; 34 void FollowRedirect(const Callback<void(URLResponsePtr)>& callback) override;
32 void QueryStatus(const Callback<void(URLLoaderStatusPtr)>& callback) override; 35 void QueryStatus(const Callback<void(URLLoaderStatusPtr)>& callback) override;
33 36
37 // ErrorHandler methods:
38 void OnConnectionError() override;
39
34 // net::URLRequest::Delegate methods: 40 // net::URLRequest::Delegate methods:
35 void OnReceivedRedirect(net::URLRequest* url_request, 41 void OnReceivedRedirect(net::URLRequest* url_request,
36 const net::RedirectInfo& redirect_info, 42 const net::RedirectInfo& redirect_info,
37 bool* defer_redirect) override; 43 bool* defer_redirect) override;
38 void OnResponseStarted(net::URLRequest* url_request) override; 44 void OnResponseStarted(net::URLRequest* url_request) override;
39 void OnReadCompleted(net::URLRequest* url_request, int bytes_read) override; 45 void OnReadCompleted(net::URLRequest* url_request, int bytes_read) override;
40 46
41 void SendError( 47 void SendError(
42 int error, 48 int error,
43 const Callback<void(URLResponsePtr)>& callback); 49 const Callback<void(URLResponsePtr)>& callback);
44 void SendResponse(URLResponsePtr response); 50 void SendResponse(URLResponsePtr response);
45 void OnResponseBodyStreamReady(MojoResult result); 51 void OnResponseBodyStreamReady(MojoResult result);
52 void OnResponseBodyStreamClosed(MojoResult result);
46 void ReadMore(); 53 void ReadMore();
47 void DidRead(uint32_t num_bytes, bool completed_synchronously); 54 void DidRead(uint32_t num_bytes, bool completed_synchronously);
55 void ListenForPeerClosed();
56 void DeleteIfNeeded();
48 57
49 NetworkContext* context_; 58 NetworkContext* context_;
50 scoped_ptr<net::URLRequest> url_request_; 59 scoped_ptr<net::URLRequest> url_request_;
51 Callback<void(URLResponsePtr)> callback_; 60 Callback<void(URLResponsePtr)> callback_;
52 ScopedDataPipeProducerHandle response_body_stream_; 61 ScopedDataPipeProducerHandle response_body_stream_;
53 scoped_refptr<NetToMojoPendingBuffer> pending_write_; 62 scoped_refptr<NetToMojoPendingBuffer> pending_write_;
54 common::HandleWatcher handle_watcher_; 63 common::HandleWatcher handle_watcher_;
55 uint32 response_body_buffer_size_; 64 uint32 response_body_buffer_size_;
56 bool auto_follow_redirects_; 65 bool auto_follow_redirects_;
66 bool connected_;
67 Binding<URLLoader> binding_;
57 68
58 base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_; 69 base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_;
59 }; 70 };
60 71
61 } // namespace mojo 72 } // namespace mojo
62 73
63 #endif // MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_ 74 #endif // MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_
OLDNEW
« no previous file with comments | « mojo/services/network/udp_socket_apptest.cc ('k') | mojo/services/network/url_loader_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698