| Index: net/cronet/android/url_request_context_peer.h
|
| diff --git a/net/cronet/android/url_request_context_peer.h b/net/cronet/android/url_request_context_peer.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3127b5c08379c1c311940557b2e1f0d27790aea0
|
| --- /dev/null
|
| +++ b/net/cronet/android/url_request_context_peer.h
|
| @@ -0,0 +1,76 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef NET_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_
|
| +#define NET_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_
|
| +
|
| +#include "base/threading/thread.h"
|
| +#include "net/cronet/android/android_log.h"
|
| +#include "net/url_request/url_request_context.h"
|
| +#include "net/url_request/url_request_context_getter.h"
|
| +
|
| +/*
|
| + * Implementation of the Chromium NetLog observer interface.
|
| + */
|
| +class NetLogObserver : public net::NetLog::ThreadSafeObserver {
|
| + public:
|
| + explicit NetLogObserver(LoggingLevel log_level) {
|
| + log_level_ = log_level;
|
| + }
|
| +
|
| + virtual ~NetLogObserver() {
|
| + }
|
| +
|
| + virtual void OnAddEntry(const net::NetLog::Entry& entry);
|
| + private:
|
| + LoggingLevel log_level_;
|
| +};
|
| +
|
| +/*
|
| + * Fully configured |URLRequestContext|.
|
| + */
|
| +class URLRequestContextPeer : public net::URLRequestContextGetter {
|
| + public:
|
| + class URLRequestContextPeerDelegate
|
| + : public base::RefCountedThreadSafe<URLRequestContextPeerDelegate> {
|
| + public:
|
| + virtual void OnContextInitialized(URLRequestContextPeer* context) = 0;
|
| + virtual ~URLRequestContextPeerDelegate() {}
|
| + };
|
| +
|
| + URLRequestContextPeer(URLRequestContextPeerDelegate* delegate,
|
| + std::string user_agent, LoggingLevel log_level,
|
| + const char* version);
|
| + ~URLRequestContextPeer();
|
| +
|
| + void Initialize();
|
| +
|
| + const std::string &GetUserAgent(const GURL &url) const;
|
| +
|
| + LoggingLevel logging_level() const;
|
| +
|
| + const char* version() const;
|
| +
|
| + public:
|
| + virtual net::URLRequestContext* GetURLRequestContext();
|
| + virtual scoped_refptr<base::SingleThreadTaskRunner>
|
| + GetNetworkTaskRunner() const;
|
| +
|
| + private:
|
| + scoped_refptr<URLRequestContextPeerDelegate> delegate_;
|
| + scoped_ptr<net::URLRequestContext> context_;
|
| + LoggingLevel logging_level_;
|
| + const char* version_;
|
| + std::string user_agent_;
|
| + base::Thread* network_thread_;
|
| + scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
|
| + scoped_ptr<NetLogObserver> netlog_observer_;
|
| +
|
| + // Initializes |context_| on the IO thread.
|
| + void InitializeURLRequestContext();
|
| +
|
| + DISALLOW_EVIL_CONSTRUCTORS(URLRequestContextPeer);
|
| +};
|
| +
|
| +#endif // NET_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_
|
|
|