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

Side by Side Diff: android_webview/native/aw_contents_io_thread_client_impl.cc

Issue 2485513003: Rename JavaObjectWeakGlobalRef::is_empty to avoid misuse. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | android_webview/native/popup_touch_handle_drawable.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 // TODO: currently there is only one browser context so it is ok to 266 // TODO: currently there is only one browser context so it is ok to
267 // store in a global variable, in the future use browser_context to 267 // store in a global variable, in the future use browser_context to
268 // obtain the correct instance. 268 // obtain the correct instance.
269 JavaObjectWeakGlobalRef temp(AttachCurrentThread(), jclient.obj()); 269 JavaObjectWeakGlobalRef temp(AttachCurrentThread(), jclient.obj());
270 g_sw_instance_.Get() = temp; 270 g_sw_instance_.Get() = temp;
271 } 271 }
272 272
273 // static 273 // static
274 std::unique_ptr<AwContentsIoThreadClient> 274 std::unique_ptr<AwContentsIoThreadClient>
275 AwContentsIoThreadClient::GetServiceWorkerIoThreadClient() { 275 AwContentsIoThreadClient::GetServiceWorkerIoThreadClient() {
276 if (g_sw_instance_.Get().is_empty())
277 return std::unique_ptr<AwContentsIoThreadClient>();
278
279 JNIEnv* env = AttachCurrentThread(); 276 JNIEnv* env = AttachCurrentThread();
280 ScopedJavaLocalRef<jobject> java_delegate = g_sw_instance_.Get().get(env); 277 ScopedJavaLocalRef<jobject> java_delegate = g_sw_instance_.Get().get(env);
281 278
282 DCHECK(!java_delegate.is_null()); 279 if (java_delegate.is_null())
timvolodine 2016/11/07 17:13:01 to be more precise, I was looking here and compari
boliu 2016/11/07 17:23:33 They are not equivalent. is_empty (now is_initial
boliu 2016/11/07 17:25:29 darn it, got that backwards it's possible for get
timvolodine 2016/11/07 20:16:15 Just to follow-up: we chatted here a bit about thi
280 return std::unique_ptr<AwContentsIoThreadClient>();
281
283 return std::unique_ptr<AwContentsIoThreadClient>( 282 return std::unique_ptr<AwContentsIoThreadClient>(
284 new AwContentsIoThreadClientImpl(false, java_delegate)); 283 new AwContentsIoThreadClientImpl(false, java_delegate));
285 } 284 }
286 285
287 AwContentsIoThreadClientImpl::AwContentsIoThreadClientImpl( 286 AwContentsIoThreadClientImpl::AwContentsIoThreadClientImpl(
288 bool pending_association, 287 bool pending_association,
289 const JavaRef<jobject>& obj) 288 const JavaRef<jobject>& obj)
290 : pending_association_(pending_association), 289 : pending_association_(pending_association),
291 java_object_(obj) { 290 java_object_(obj) {
292 } 291 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 Java_AwContentsIoThreadClient_onReceivedHttpError( 460 Java_AwContentsIoThreadClient_onReceivedHttpError(
462 env, java_object_, web_request.jstring_url, web_request.is_main_frame, 461 env, java_object_, web_request.jstring_url, web_request.is_main_frame,
463 web_request.has_user_gesture, web_request.jstring_method, 462 web_request.has_user_gesture, web_request.jstring_method,
464 web_request.jstringArray_header_names, 463 web_request.jstringArray_header_names,
465 web_request.jstringArray_header_values, jstring_mime_type, 464 web_request.jstringArray_header_values, jstring_mime_type,
466 jstring_encoding, status_code, jstring_reason, 465 jstring_encoding, status_code, jstring_reason,
467 jstringArray_response_header_names, jstringArray_response_header_values); 466 jstringArray_response_header_names, jstringArray_response_header_values);
468 } 467 }
469 468
470 } // namespace android_webview 469 } // namespace android_webview
OLDNEW
« no previous file with comments | « no previous file | android_webview/native/popup_touch_handle_drawable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698