OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "android_webview/native/aw_contents_io_thread_client_impl.h" | 5 #include "android_webview/native/aw_contents_io_thread_client_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 // RfhToIoThreadClientMap ----------------------------------------------------- | 64 // RfhToIoThreadClientMap ----------------------------------------------------- |
65 class RfhToIoThreadClientMap { | 65 class RfhToIoThreadClientMap { |
66 public: | 66 public: |
67 static RfhToIoThreadClientMap* GetInstance(); | 67 static RfhToIoThreadClientMap* GetInstance(); |
68 void Set(pair<int, int> rfh_id, const IoThreadClientData& client); | 68 void Set(pair<int, int> rfh_id, const IoThreadClientData& client); |
69 bool Get(pair<int, int> rfh_id, IoThreadClientData* client); | 69 bool Get(pair<int, int> rfh_id, IoThreadClientData* client); |
70 void Erase(pair<int, int> rfh_id); | 70 void Erase(pair<int, int> rfh_id); |
71 | 71 |
72 private: | 72 private: |
73 static LazyInstance<RfhToIoThreadClientMap> g_instance_; | |
74 base::Lock map_lock_; | 73 base::Lock map_lock_; |
75 RenderFrameHostToIoThreadClientType rfh_to_io_thread_client_; | 74 RenderFrameHostToIoThreadClientType rfh_to_io_thread_client_; |
76 }; | 75 }; |
77 | 76 |
78 // static | 77 // static |
79 LazyInstance<RfhToIoThreadClientMap> RfhToIoThreadClientMap::g_instance_ = | 78 LazyInstance<RfhToIoThreadClientMap>::DestructorAtExit g_instance_ = |
80 LAZY_INSTANCE_INITIALIZER; | 79 LAZY_INSTANCE_INITIALIZER; |
81 | 80 |
82 // static | 81 // static |
83 LazyInstance<JavaObjectWeakGlobalRef> g_sw_instance_ = | 82 LazyInstance<JavaObjectWeakGlobalRef>::DestructorAtExit g_sw_instance_ = |
84 LAZY_INSTANCE_INITIALIZER; | 83 LAZY_INSTANCE_INITIALIZER; |
85 | 84 |
86 // static | 85 // static |
87 RfhToIoThreadClientMap* RfhToIoThreadClientMap::GetInstance() { | 86 RfhToIoThreadClientMap* RfhToIoThreadClientMap::GetInstance() { |
88 return g_instance_.Pointer(); | 87 return g_instance_.Pointer(); |
89 } | 88 } |
90 | 89 |
91 void RfhToIoThreadClientMap::Set(pair<int, int> rfh_id, | 90 void RfhToIoThreadClientMap::Set(pair<int, int> rfh_id, |
92 const IoThreadClientData& client) { | 91 const IoThreadClientData& client) { |
93 base::AutoLock lock(map_lock_); | 92 base::AutoLock lock(map_lock_); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 346 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
348 if (java_object_.is_null()) | 347 if (java_object_.is_null()) |
349 return false; | 348 return false; |
350 | 349 |
351 JNIEnv* env = AttachCurrentThread(); | 350 JNIEnv* env = AttachCurrentThread(); |
352 return Java_AwContentsIoThreadClient_shouldBlockNetworkLoads(env, | 351 return Java_AwContentsIoThreadClient_shouldBlockNetworkLoads(env, |
353 java_object_); | 352 java_object_); |
354 } | 353 } |
355 | 354 |
356 } // namespace android_webview | 355 } // namespace android_webview |
OLD | NEW |