Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: components/cronet/android/cronet_url_request_context_adapter.h

Issue 922283002: Use @NativeClassQualifiedName in CronetUrlRequestContext.java (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Matt's comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ 5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_
6 #define COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ 6 #define COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_
7 7
8 #include <jni.h>
9
8 #include <queue> 10 #include <queue>
9 #include <string> 11 #include <string>
10 12
13 #include "base/android/scoped_java_ref.h"
11 #include "base/callback.h" 14 #include "base/callback.h"
12 #include "base/macros.h" 15 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
15 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
16 #include "net/base/net_log.h"
17 #include "net/base/network_change_notifier.h"
18 19
19 namespace base { 20 namespace base {
20 class SingleThreadTaskRunner; 21 class SingleThreadTaskRunner;
21 } // namespace base 22 } // namespace base
22 23
23 namespace net { 24 namespace net {
24 class NetLogLogger; 25 class NetLogLogger;
25 class URLRequestContext; 26 class URLRequestContext;
26 class ProxyConfigService; 27 class ProxyConfigService;
27 } // namespace net 28 } // namespace net
28 29
29 namespace cronet { 30 namespace cronet {
30 31
32 bool CronetUrlRequestContextAdapterRegisterJni(JNIEnv* env);
33
31 struct URLRequestContextConfig; 34 struct URLRequestContextConfig;
32 35
33 // Adapter between Java CronetUrlRequestContext and net::URLRequestContext. 36 // Adapter between Java CronetUrlRequestContext and net::URLRequestContext.
34 class CronetURLRequestContextAdapter { 37 class CronetURLRequestContextAdapter {
35 public: 38 public:
36 explicit CronetURLRequestContextAdapter( 39 explicit CronetURLRequestContextAdapter(
37 scoped_ptr<URLRequestContextConfig> context_config); 40 scoped_ptr<URLRequestContextConfig> context_config);
38 41
39 ~CronetURLRequestContextAdapter(); 42 ~CronetURLRequestContextAdapter();
40 43
41 // Called on main Java thread to initialize URLRequestContext. 44 // Called on main Java thread to initialize URLRequestContext.
42 void InitRequestContextOnMainThread( 45 void InitRequestContextOnMainThread(JNIEnv* env, jobject jcaller);
43 const base::Closure& java_init_network_thread);
44 46
45 // Releases all resources for the request context and deletes the object. 47 // Releases all resources for the request context and deletes the object.
46 // Blocks until network thread is destroyed after running all pending tasks. 48 // Blocks until network thread is destroyed after running all pending tasks.
47 void Destroy(); 49 void Destroy(JNIEnv* env, jobject jcaller);
48 50
49 // Posts a task that might depend on the context being initialized 51 // Posts a task that might depend on the context being initialized
50 // to the network thread. 52 // to the network thread.
51 void PostTaskToNetworkThread(const tracked_objects::Location& posted_from, 53 void PostTaskToNetworkThread(const tracked_objects::Location& posted_from,
52 const base::Closure& callback); 54 const base::Closure& callback);
53 55
54 bool IsOnNetworkThread() const; 56 bool IsOnNetworkThread() const;
55 57
56 net::URLRequestContext* GetURLRequestContext(); 58 net::URLRequestContext* GetURLRequestContext();
57 59
58 void StartNetLogToFile(const std::string& file_name); 60 void StartNetLogToFile(JNIEnv* env, jobject jcaller, jstring jfile_name);
59 61
60 void StopNetLog(); 62 void StopNetLog(JNIEnv* env, jobject jcaller);
61 63
62 // Default net::LOAD flags used to create requests. 64 // Default net::LOAD flags used to create requests.
63 int default_load_flags() const { return default_load_flags_; } 65 int default_load_flags() const { return default_load_flags_; }
64 66
65 // Called on main Java thread to initialize URLRequestContext. 67 // Called on main Java thread to initialize URLRequestContext.
66 void InitRequestContextOnMainThread(); 68 void InitRequestContextOnMainThread();
67 69
68 private: 70 private:
69 // Initializes |context_| on the Network thread. 71 // Initializes |context_| on the Network thread.
70 void InitializeOnNetworkThread( 72 void InitializeOnNetworkThread(scoped_ptr<URLRequestContextConfig> config,
71 scoped_ptr<URLRequestContextConfig> config, 73 const base::android::ScopedJavaGlobalRef<
72 const base::Closure& java_init_network_thread); 74 jobject>& jcronet_url_request_context);
73 75
74 // Runs a task that might depend on the context being initialized. 76 // Runs a task that might depend on the context being initialized.
75 // This method should only be run on the network thread. 77 // This method should only be run on the network thread.
76 void RunTaskAfterContextInitOnNetworkThread( 78 void RunTaskAfterContextInitOnNetworkThread(
77 const base::Closure& task_to_run_after_context_init); 79 const base::Closure& task_to_run_after_context_init);
78 80
79 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const; 81 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const;
80 82
81 void StartNetLogToFileOnNetworkThread(const std::string& file_name); 83 void StartNetLogToFileOnNetworkThread(const std::string& file_name);
82 84
(...skipping 13 matching lines...) Expand all
96 std::queue<base::Closure> tasks_waiting_for_context_; 98 std::queue<base::Closure> tasks_waiting_for_context_;
97 bool is_context_initialized_; 99 bool is_context_initialized_;
98 int default_load_flags_; 100 int default_load_flags_;
99 101
100 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter); 102 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter);
101 }; 103 };
102 104
103 } // namespace cronet 105 } // namespace cronet
104 106
105 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ 107 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698