Correctly track texture cleared state for sharing
[chromium-blink-merge.git] / components / cronet / android / cronet_url_request_context_adapter.h
blobb9d1e307da7974b397118e444531b4571ccd0823
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 COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_
6 #define COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/thread.h"
15 #include "net/base/net_log.h"
16 #include "net/base/network_change_notifier.h"
18 namespace base {
19 class SingleThreadTaskRunner;
20 } // namespace base
22 namespace net {
23 class NetLogLogger;
24 class URLRequestContext;
25 } // namespace net
27 namespace cronet {
29 struct URLRequestContextConfig;
31 // Adapter between Java CronetUrlRequestContext and net::URLRequestContext.
32 class CronetURLRequestContextAdapter {
33 public:
34 CronetURLRequestContextAdapter();
36 ~CronetURLRequestContextAdapter();
38 void Initialize(scoped_ptr<URLRequestContextConfig> config,
39 const base::Closure& java_init_network_thread);
41 // Releases all resources for the request context and deletes the object.
42 // Blocks until network thread is destroyed after running all pending tasks.
43 void Destroy();
45 net::URLRequestContext* GetURLRequestContext();
47 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const;
49 void StartNetLogToFile(const std::string& file_name);
51 void StopNetLog();
53 // Default net::LOAD flags used to create requests.
54 int default_load_flags() const { return default_load_flags_; }
56 private:
57 // Initializes |context_| on the Network thread.
58 void InitializeOnNetworkThread(
59 scoped_ptr<URLRequestContextConfig> config,
60 const base::Closure& java_init_network_thread);
61 void StartNetLogToFileOnNetworkThread(const std::string& file_name);
62 void StopNetLogOnNetworkThread();
64 // Network thread is owned by |this|, but is destroyed from java thread.
65 base::Thread* network_thread_;
66 // |net_log_logger_| and |context_| should only be accessed on network thread.
67 scoped_ptr<net::NetLogLogger> net_log_logger_;
68 scoped_ptr<net::URLRequestContext> context_;
69 int default_load_flags_;
71 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter);
74 } // namespace cronet
76 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_