cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / mojo / services / network / url_loader_impl.h
blob88bf89c05b4a90d43973d88e7280545fbb9e2dd9
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
3 // found in the LICENSE file.
5 #ifndef MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_
6 #define MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h"
10 #include "mojo/application/public/cpp/app_lifetime_helper.h"
11 #include "mojo/message_pump/handle_watcher.h"
12 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
13 #include "net/base/net_errors.h"
14 #include "net/url_request/url_request.h"
15 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
17 namespace mojo {
19 class NetworkContext;
20 class NetToMojoPendingBuffer;
22 class URLLoaderImpl : public URLLoader,
23 public net::URLRequest::Delegate {
24 public:
25 URLLoaderImpl(NetworkContext* context,
26 InterfaceRequest<URLLoader> request,
27 scoped_ptr<mojo::AppRefCount> app_refcount);
28 ~URLLoaderImpl() override;
30 // Called when the associated NetworkContext is going away.
31 void Cleanup();
33 private:
34 // URLLoader methods:
35 void Start(URLRequestPtr request,
36 const Callback<void(URLResponsePtr)>& callback) override;
37 void FollowRedirect(const Callback<void(URLResponsePtr)>& callback) override;
38 void QueryStatus(const Callback<void(URLLoaderStatusPtr)>& callback) override;
40 void OnConnectionError();
42 // net::URLRequest::Delegate methods:
43 void OnReceivedRedirect(net::URLRequest* url_request,
44 const net::RedirectInfo& redirect_info,
45 bool* defer_redirect) override;
46 void OnResponseStarted(net::URLRequest* url_request) override;
47 void OnReadCompleted(net::URLRequest* url_request, int bytes_read) override;
49 void SendError(
50 int error,
51 const Callback<void(URLResponsePtr)>& callback);
52 void SendResponse(URLResponsePtr response);
53 void OnResponseBodyStreamReady(MojoResult result);
54 void OnResponseBodyStreamClosed(MojoResult result);
55 void ReadMore();
56 void DidRead(uint32_t num_bytes, bool completed_synchronously);
57 void ListenForPeerClosed();
58 void DeleteIfNeeded();
60 NetworkContext* context_;
61 scoped_ptr<net::URLRequest> url_request_;
62 Callback<void(URLResponsePtr)> callback_;
63 ScopedDataPipeProducerHandle response_body_stream_;
64 scoped_refptr<NetToMojoPendingBuffer> pending_write_;
65 common::HandleWatcher handle_watcher_;
66 uint32 response_body_buffer_size_;
67 bool auto_follow_redirects_;
68 bool connected_;
69 Binding<URLLoader> binding_;
70 scoped_ptr<mojo::AppRefCount> app_refcount_;
72 base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_;
75 } // namespace mojo
77 #endif // MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_