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/java/java_bridge_dispatcher_host.cc

Issue 14335017: content: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 | 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/java/java_bridge_dispatcher_host.h" 5 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "content/browser/renderer_host/java/java_bridge_channel_host.h" 10 #include "content/browser/renderer_host/java/java_bridge_channel_host.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 WebKit::WebBindings::retainObject(object); 132 WebKit::WebBindings::retainObject(object);
133 g_background_thread.Get().message_loop()->PostTask( 133 g_background_thread.Get().message_loop()->PostTask(
134 FROM_HERE, 134 FROM_HERE,
135 base::Bind(&JavaBridgeDispatcherHost::CreateObjectStub, this, object, 135 base::Bind(&JavaBridgeDispatcherHost::CreateObjectStub, this, object,
136 route_id)); 136 route_id));
137 } 137 }
138 138
139 void JavaBridgeDispatcherHost::CreateObjectStub(NPObject* object, 139 void JavaBridgeDispatcherHost::CreateObjectStub(NPObject* object,
140 int route_id) { 140 int route_id) {
141 DCHECK_EQ(g_background_thread.Get().message_loop(), MessageLoop::current()); 141 DCHECK_EQ(g_background_thread.Get().message_loop(),
142 base::MessageLoop::current());
142 if (!channel_) { 143 if (!channel_) {
143 channel_ = JavaBridgeChannelHost::GetJavaBridgeChannelHost( 144 channel_ = JavaBridgeChannelHost::GetJavaBridgeChannelHost(
144 render_view_host()->GetProcess()->GetID(), 145 render_view_host()->GetProcess()->GetID(),
145 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 146 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
146 } 147 }
147 148
148 // In a typical scenario, the lifetime of each NPObjectStub is governed by 149 // In a typical scenario, the lifetime of each NPObjectStub is governed by
149 // that of the NPObjectProxy in the renderer, via the channel. However, 150 // that of the NPObjectProxy in the renderer, via the channel. However,
150 // we cannot guaranteed that the renderer always terminates cleanly 151 // we cannot guaranteed that the renderer always terminates cleanly
151 // (crashes / sometimes just unavoidable). We keep a weak reference to 152 // (crashes / sometimes just unavoidable). We keep a weak reference to
152 // it now and schedule a delete on it when this host is getting deleted. 153 // it now and schedule a delete on it when this host is getting deleted.
153 154
154 // Pass 0 for the containing window, as it's only used by plugins to pump the 155 // Pass 0 for the containing window, as it's only used by plugins to pump the
155 // window message queue when a method on a renderer-side object causes a 156 // window message queue when a method on a renderer-side object causes a
156 // dialog to be displayed, and the Java Bridge does not need this 157 // dialog to be displayed, and the Java Bridge does not need this
157 // functionality. The page URL is also not required. 158 // functionality. The page URL is also not required.
158 stubs_.push_back( 159 stubs_.push_back(
159 (new NPObjectStub(object, channel_, route_id, 0, GURL()))->AsWeakPtr()); 160 (new NPObjectStub(object, channel_, route_id, 0, GURL()))->AsWeakPtr());
160 161
161 // The NPObjectStub takes a reference to the NPObject. Release the ref added 162 // The NPObjectStub takes a reference to the NPObject. Release the ref added
162 // in CreateNPVariantParam(). 163 // in CreateNPVariantParam().
163 WebKit::WebBindings::releaseObject(object); 164 WebKit::WebBindings::releaseObject(object);
164 } 165 }
165 166
166 } // namespace content 167 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698