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/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.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"
19 class URLLoaderImpl : public InterfaceImpl<URLLoader>,
20 public net::URLRequest::Delegate {
22 explicit URLLoaderImpl(NetworkContext* context);
23 virtual ~URLLoaderImpl();
26 class PendingWriteToDataPipe;
27 class DependentIOBuffer;
29 // InterfaceImpl<> methods:
30 virtual void OnConnectionError() OVERRIDE;
34 URLRequestPtr request,
35 ScopedDataPipeProducerHandle response_body_stream) OVERRIDE;
36 virtual void FollowRedirect() OVERRIDE;
38 // net::URLRequest::Delegate methods:
39 virtual void OnReceivedRedirect(net::URLRequest* url_request,
41 bool* defer_redirect) OVERRIDE;
42 virtual void OnResponseStarted(net::URLRequest* url_request) OVERRIDE;
43 virtual void OnReadCompleted(net::URLRequest* url_request, int bytes_read)
46 void SendError(int error);
48 void DidRead(uint32_t num_bytes, bool completed_synchronously);
50 NetworkContext* context_;
51 scoped_ptr<net::URLRequest> url_request_;
52 ScopedDataPipeProducerHandle response_body_stream_;
53 scoped_refptr<PendingWriteToDataPipe> pending_write_;
54 bool auto_follow_redirects_;
56 base::WeakPtrFactory<URLLoaderImpl> weak_ptr_factory_;
61 #endif // MOJO_SERVICES_NETWORK_URL_LOADER_IMPL_H_