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

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 2422923002: Reduce usage of FOR_EACH_OBSERVER macro in content/browser (Closed)
Patch Set: skip cases in 2418143004 and 2418373002 Created 4 years, 2 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
« no previous file with comments | « no previous file | content/browser/appcache/appcache_group.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "content/browser/android/content_view_core_impl.h" 5 #include "content/browser/android/content_view_core_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 observer_list_.AddObserver(observer); 251 observer_list_.AddObserver(observer);
252 } 252 }
253 253
254 void ContentViewCoreImpl::RemoveObserver( 254 void ContentViewCoreImpl::RemoveObserver(
255 ContentViewCoreImplObserver* observer) { 255 ContentViewCoreImplObserver* observer) {
256 observer_list_.RemoveObserver(observer); 256 observer_list_.RemoveObserver(observer);
257 } 257 }
258 258
259 ContentViewCoreImpl::~ContentViewCoreImpl() { 259 ContentViewCoreImpl::~ContentViewCoreImpl() {
260 view_.GetLayer()->RemoveFromParent(); 260 view_.GetLayer()->RemoveFromParent();
261 FOR_EACH_OBSERVER(ContentViewCoreImplObserver, 261 for (auto& observer : observer_list_)
262 observer_list_, 262 observer.OnContentViewCoreDestroyed();
263 OnContentViewCoreDestroyed());
264 observer_list_.Clear(); 263 observer_list_.Clear();
265 264
266 JNIEnv* env = base::android::AttachCurrentThread(); 265 JNIEnv* env = base::android::AttachCurrentThread();
267 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 266 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
268 java_ref_.reset(); 267 java_ref_.reset();
269 if (!j_obj.is_null()) { 268 if (!j_obj.is_null()) {
270 Java_ContentViewCore_onNativeContentViewCoreDestroyed( 269 Java_ContentViewCore_onNativeContentViewCoreDestroyed(
271 env, j_obj, reinterpret_cast<intptr_t>(this)); 270 env, j_obj, reinterpret_cast<intptr_t>(this));
272 } 271 }
273 } 272 }
274 273
275 void ContentViewCoreImpl::UpdateWindowAndroid( 274 void ContentViewCoreImpl::UpdateWindowAndroid(
276 JNIEnv* env, 275 JNIEnv* env,
277 const base::android::JavaParamRef<jobject>& obj, 276 const base::android::JavaParamRef<jobject>& obj,
278 jlong window_android) { 277 jlong window_android) {
279 if (window_android) { 278 if (window_android) {
280 DCHECK(!view_.GetWindowAndroid()); 279 DCHECK(!view_.GetWindowAndroid());
281 ui::WindowAndroid* window = 280 ui::WindowAndroid* window =
282 reinterpret_cast<ui::WindowAndroid*>(window_android); 281 reinterpret_cast<ui::WindowAndroid*>(window_android);
283 window->AddChild(&view_); 282 window->AddChild(&view_);
284 FOR_EACH_OBSERVER(ContentViewCoreImplObserver, 283 for (auto& observer : observer_list_)
285 observer_list_, 284 observer.OnAttachedToWindow();
286 OnAttachedToWindow());
287 } else { 285 } else {
288 FOR_EACH_OBSERVER(ContentViewCoreImplObserver, 286 for (auto& observer : observer_list_)
289 observer_list_, 287 observer.OnDetachedFromWindow();
290 OnDetachedFromWindow());
291 view_.RemoveFromParent(); 288 view_.RemoveFromParent();
292 } 289 }
293 } 290 }
294 291
295 base::android::ScopedJavaLocalRef<jobject> 292 base::android::ScopedJavaLocalRef<jobject>
296 ContentViewCoreImpl::GetWebContentsAndroid(JNIEnv* env, 293 ContentViewCoreImpl::GetWebContentsAndroid(JNIEnv* env,
297 const JavaParamRef<jobject>& obj) { 294 const JavaParamRef<jobject>& obj) {
298 return web_contents_->GetJavaWebContents(); 295 return web_contents_->GetJavaWebContents();
299 } 296 }
300 297
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1570 return ScopedJavaLocalRef<jobject>(); 1567 return ScopedJavaLocalRef<jobject>();
1571 1568
1572 return view->GetJavaObject(); 1569 return view->GetJavaObject();
1573 } 1570 }
1574 1571
1575 bool RegisterContentViewCore(JNIEnv* env) { 1572 bool RegisterContentViewCore(JNIEnv* env) {
1576 return RegisterNativesImpl(env); 1573 return RegisterNativesImpl(env);
1577 } 1574 }
1578 1575
1579 } // namespace content 1576 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/appcache/appcache_group.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698