Chromium Code Reviews| Index: components/cronet/android/cronet_url_request_context_adapter.h |
| diff --git a/components/cronet/android/cronet_url_request_context_adapter.h b/components/cronet/android/cronet_url_request_context_adapter.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..48509499798de662cbc26a0faeb33a30d4722608 |
| --- /dev/null |
| +++ b/components/cronet/android/cronet_url_request_context_adapter.h |
| @@ -0,0 +1,83 @@ |
| +// 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 COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ |
| +#define COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/compiler_specific.h" |
|
xunjieli
2014/10/23 14:04:33
Is this include being used?
mef
2014/10/24 03:31:44
I think it used to define OVERRIDE, which is no lo
|
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/threading/thread.h" |
| +#include "net/base/net_log.h" |
| +#include "net/base/network_change_notifier.h" |
| +#include "net/url_request/url_request_context_getter.h" |
| + |
| +namespace base { |
| +class SingleThreadTaskRunner; |
| +} // namespace base |
| + |
| +namespace net { |
| +class NetLogLogger; |
| +class URLRequestContext; |
| +} // namespace net |
| + |
| +namespace cronet { |
| + |
| +struct URLRequestContextConfig; |
| + |
| +// Fully configured |URLRequestContext|. |
|
xunjieli
2014/10/23 14:04:33
nit: This comment does not make much sense to me.
mef
2014/10/24 03:31:44
Done.
|
| +class CronetURLRequestContextAdapter : public net::URLRequestContextGetter { |
|
mmenke
2014/10/23 16:26:01
I don't think this works for cleanup - threads hav
mef
2014/10/24 19:57:55
Done.
|
| + public: |
| + class CronetURLRequestContextAdapterDelegate |
| + : public base::RefCountedThreadSafe< |
| + CronetURLRequestContextAdapterDelegate> { |
| + public: |
| + virtual void OnContextInitialized( |
| + CronetURLRequestContextAdapter* context_adapter) = 0; |
| + |
| + protected: |
| + friend class base::RefCountedThreadSafe< |
| + CronetURLRequestContextAdapterDelegate>; |
| + |
| + virtual ~CronetURLRequestContextAdapterDelegate() {} |
| + }; |
| + |
| + explicit CronetURLRequestContextAdapter( |
| + CronetURLRequestContextAdapterDelegate* delegate); |
| + void Initialize(scoped_ptr<URLRequestContextConfig> config); |
| + |
| + const std::string& GetUserAgent(const GURL& url) const; |
|
mmenke
2014/10/23 16:26:01
Should get rid of this and just set it on the cont
mef
2014/10/24 03:31:44
Done.
|
| + |
| + // net::URLRequestContextGetter implementation: |
| + net::URLRequestContext* GetURLRequestContext() override; |
| + scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
| + const override; |
| + |
| + void StartNetLogToFile(const std::string& file_name); |
| + void StopNetLog(); |
| + |
| + private: |
| + scoped_refptr<CronetURLRequestContextAdapterDelegate> delegate_; |
| + scoped_ptr<net::URLRequestContext> context_; |
| + std::string user_agent_; |
| + base::Thread* network_thread_; |
| + scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
|
xunjieli
2014/10/23 14:04:33
nit: I don't think this is being used. Suggest als
mef
2014/10/24 03:31:44
Done.
|
| + scoped_ptr<net::NetLogLogger> net_log_logger_; |
| + |
| + virtual ~CronetURLRequestContextAdapter(); |
| + |
| + // Initializes |context_| on the Network thread. |
| + void InitializeOnNetworkThread(scoped_ptr<URLRequestContextConfig> config); |
| + void StartNetLogToFileOnNetworkThread(const std::string& file_name); |
| + void StopNetLogOnNetworkThread(); |
| + |
| + DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter); |
| +}; |
| + |
| +} // namespace cronet |
| + |
| +#endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ |