Update media/audio to use the new version of LaunchProcess.
[chromium-blink-merge.git] / mojo / services / network / url_loader_impl.h
blobdec48d57a033a4c06a658b0de2bae78a55c15b9b
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/common/handle_watcher.h"
11 #include "mojo/public/cpp/bindings/interface_impl.h"
12 #include "mojo/services/public/interfaces/network/url_loader.mojom.h"
13 #include "net/base/net_errors.h"
14 #include "net/url_request/url_request.h"
16 namespace mojo {
18 class NetworkContext;
19 class NetToMojoPendingBuffer;
21 class URLLoaderImpl : public InterfaceImpl<URLLoader>,
22 public net::URLRequest::Delegate {
23 public:
24 explicit URLLoaderImpl(NetworkContext* context);
25 ~URLLoaderImpl() override;
27 private:
28 // URLLoader methods:
29 void Start(URLRequestPtr request,
30 const Callback<void(URLResponsePtr)>& callback) override;
31 void FollowRedirect(const Callback<void(URLResponsePtr)>& callback) override;
32 void QueryStatus(const Callback<void(URLLoaderStatusPtr)>& callback) override;
34 // net::URLRequest::Delegate methods:
35 void OnReceivedRedirect(net::URLRequest* url_request,
36 const net::RedirectInfo& redirect_info,
37 bool* defer_redirect) override;
38 void OnResponseStarted(net::URLRequest* url_request) override;
39 void OnReadCompleted(net::URLRequest* url_request, int bytes_read) override;
41 void SendError(
42 int error,
43 const Callback<void(URLResponsePtr)>& callback);
44 void SendResponse(URLResponsePtr response);
45 void OnResponseBodyStreamReady(MojoResult result);
46 void ReadMore();
47 void DidRead(uint32_t num_bytes, bool completed_synchronously);
49 NetworkContext* context_;
50 scoped_ptr<net::URLRequest> url_request_;
51 Callback<void(URLResponsePtr)> callback_;
52 ScopedDataPipeProducerHandle response_body_stream_;
53 scoped_refptr<NetToMojoPendingBuffer> pending_write_;
54 common::HandleWatcher handle_watcher_;
55 uint32 response_body_buffer_size_;
56 bool auto_follow_redirects_;
58 base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_;
61 } // namespace mojo
63 #endif // MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_