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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 63803002: Remove RenderWidgetHost::AddCreatedCallback as part of removing that pattern. The tests which use t… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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 | Annotate | Revision Log
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 "content/browser/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 namespace { 84 namespace {
85 85
86 bool g_check_for_pending_resize_ack = true; 86 bool g_check_for_pending_resize_ack = true;
87 87
88 // How long to (synchronously) wait for the renderer to respond with a 88 // How long to (synchronously) wait for the renderer to respond with a
89 // PaintRect message, when our backing-store is invalid, before giving up and 89 // PaintRect message, when our backing-store is invalid, before giving up and
90 // returning a null or incorrectly sized backing-store from GetBackingStore. 90 // returning a null or incorrectly sized backing-store from GetBackingStore.
91 // This timeout impacts the "choppiness" of our window resize perf. 91 // This timeout impacts the "choppiness" of our window resize perf.
92 const int kPaintMsgTimeoutMS = 50; 92 const int kPaintMsgTimeoutMS = 50;
93 93
94 base::LazyInstance<std::vector<RenderWidgetHost::CreatedCallback> >
95 g_created_callbacks = LAZY_INSTANCE_INITIALIZER;
96
97 typedef std::pair<int32, int32> RenderWidgetHostID; 94 typedef std::pair<int32, int32> RenderWidgetHostID;
98 typedef base::hash_map<RenderWidgetHostID, RenderWidgetHostImpl*> 95 typedef base::hash_map<RenderWidgetHostID, RenderWidgetHostImpl*>
99 RoutingIDWidgetMap; 96 RoutingIDWidgetMap;
100 base::LazyInstance<RoutingIDWidgetMap> g_routing_id_widget_map = 97 base::LazyInstance<RoutingIDWidgetMap> g_routing_id_widget_map =
101 LAZY_INSTANCE_INITIALIZER; 98 LAZY_INSTANCE_INITIALIZER;
102 99
103 // Implements the RenderWidgetHostIterator interface. It keeps a list of 100 // Implements the RenderWidgetHostIterator interface. It keeps a list of
104 // RenderWidgetHosts, and makes sure it returns a live RenderWidgetHost at each 101 // RenderWidgetHosts, and makes sure it returns a live RenderWidgetHost at each
105 // iteration (or NULL if there isn't any left). 102 // iteration (or NULL if there isn't any left).
106 class RenderWidgetHostIteratorImpl : public RenderWidgetHostIterator { 103 class RenderWidgetHostIteratorImpl : public RenderWidgetHostIterator {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 process_->AddRoute(routing_id_, this); 215 process_->AddRoute(routing_id_, this);
219 216
220 // If we're initially visible, tell the process host that we're alive. 217 // If we're initially visible, tell the process host that we're alive.
221 // Otherwise we'll notify the process host when we are first shown. 218 // Otherwise we'll notify the process host when we are first shown.
222 if (!hidden) 219 if (!hidden)
223 process_->WidgetRestored(); 220 process_->WidgetRestored();
224 221
225 accessibility_mode_ = 222 accessibility_mode_ =
226 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode(); 223 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode();
227 224
228 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++)
229 g_created_callbacks.Get().at(i).Run(this);
230
231 input_router_.reset( 225 input_router_.reset(
232 new ImmediateInputRouter(process_, this, this, routing_id_)); 226 new ImmediateInputRouter(process_, this, this, routing_id_));
233 227
234 #if defined(USE_AURA) 228 #if defined(USE_AURA)
235 bool overscroll_enabled = CommandLine::ForCurrentProcess()-> 229 bool overscroll_enabled = CommandLine::ForCurrentProcess()->
236 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; 230 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0";
237 SetOverscrollControllerEnabled(overscroll_enabled); 231 SetOverscrollControllerEnabled(overscroll_enabled);
238 #endif 232 #endif
239 } 233 }
240 234
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 302 }
309 303
310 return scoped_ptr<RenderWidgetHostIterator>(hosts); 304 return scoped_ptr<RenderWidgetHostIterator>(hosts);
311 } 305 }
312 306
313 // static 307 // static
314 RenderWidgetHostImpl* RenderWidgetHostImpl::From(RenderWidgetHost* rwh) { 308 RenderWidgetHostImpl* RenderWidgetHostImpl::From(RenderWidgetHost* rwh) {
315 return rwh->AsRenderWidgetHostImpl(); 309 return rwh->AsRenderWidgetHostImpl();
316 } 310 }
317 311
318 // static
319 void RenderWidgetHost::AddCreatedCallback(const CreatedCallback& callback) {
320 g_created_callbacks.Get().push_back(callback);
321 }
322
323 // static
324 void RenderWidgetHost::RemoveCreatedCallback(const CreatedCallback& callback) {
325 for (size_t i = 0; i < g_created_callbacks.Get().size(); ++i) {
326 if (g_created_callbacks.Get().at(i).Equals(callback)) {
327 g_created_callbacks.Get().erase(g_created_callbacks.Get().begin() + i);
328 return;
329 }
330 }
331 }
332
333 void RenderWidgetHostImpl::SetView(RenderWidgetHostView* view) { 312 void RenderWidgetHostImpl::SetView(RenderWidgetHostView* view) {
334 view_ = RenderWidgetHostViewPort::FromRWHV(view); 313 view_ = RenderWidgetHostViewPort::FromRWHV(view);
335 314
336 if (!view_) { 315 if (!view_) {
337 GpuSurfaceTracker::Get()->SetSurfaceHandle( 316 GpuSurfaceTracker::Get()->SetSurfaceHandle(
338 surface_id_, gfx::GLSurfaceHandle()); 317 surface_id_, gfx::GLSurfaceHandle());
339 } 318 }
340 } 319 }
341 320
342 RenderProcessHost* RenderWidgetHostImpl::GetProcess() const { 321 RenderProcessHost* RenderWidgetHostImpl::GetProcess() const {
(...skipping 2155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2498 continue; 2477 continue;
2499 } 2478 }
2500 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); 2479 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh);
2501 if (rwhi_set.insert(rwhi).second) 2480 if (rwhi_set.insert(rwhi).second)
2502 rwhi->FrameSwapped(latency_info); 2481 rwhi->FrameSwapped(latency_info);
2503 } 2482 }
2504 } 2483 }
2505 } 2484 }
2506 2485
2507 } // namespace content 2486 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/apps/web_view_interactive_browsertest.cc ('k') | content/public/browser/render_widget_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698