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

Side by Side Diff: content/browser/renderer_host/java/java_bridge_dispatcher_host.cc

Issue 18584006: Making a way to create thread with a Java Looper for Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed name to HandlerThread Created 7 years, 5 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
« base/android/java_handler_thread.cc ('K') | « base/base.gypi ('k') | no next file » | 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 "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"
10 #include "content/browser/renderer_host/java/java_bridge_channel_host.h" 9 #include "content/browser/renderer_host/java/java_bridge_channel_host.h"
11 #include "content/browser/renderer_host/render_view_host_impl.h" 10 #include "content/browser/renderer_host/render_view_host_impl.h"
12 #include "content/child/child_process.h" 11 #include "content/child/child_process.h"
13 #include "content/child/npobject_stub.h" 12 #include "content/child/npobject_stub.h"
14 #include "content/child/npobject_util.h" // For CreateNPVariantParam() 13 #include "content/child/npobject_util.h" // For CreateNPVariantParam()
15 #include "content/common/java_bridge_messages.h" 14 #include "content/common/java_bridge_messages.h"
16 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/render_process_host.h" 16 #include "content/public/browser/render_process_host.h"
18 #include "third_party/WebKit/public/web/WebBindings.h" 17 #include "third_party/WebKit/public/web/WebBindings.h"
19 18
19 #if defined(OS_ANDROID)
20 #include "base/android/java_handler_thread.h"
21 #else
22 #include "base/threading/thread.h"
joth 2013/07/17 21:16:19 I don't see what purpose this is serving - I don't
Kristian Monsen 2013/07/17 21:54:40 True, updated.
23 #endif
24
25 // Android needs to use a Java thread so the callback
26 // will happen on a thread with a prepared Looper.
27 #if defined(OS_ANDROID)
28 typedef base::android::JavaHandlerThread THREAD;
29 #else
30 typedef base::Thread THREAD;
31 #endif
32
20 namespace content { 33 namespace content {
21 34
22 namespace { 35 namespace {
23 class JavaBridgeThread : public base::Thread { 36 class JavaBridgeThread : public THREAD {
24 public: 37 public:
25 JavaBridgeThread() : base::Thread("JavaBridge") { 38 JavaBridgeThread() : THREAD("JavaBridge") {
26 Start(); 39 Start();
27 } 40 }
28 virtual ~JavaBridgeThread() { 41 virtual ~JavaBridgeThread() {
29 Stop(); 42 Stop();
30 } 43 }
31 }; 44 };
32 45
33 void CleanUpStubs(const std::vector<base::WeakPtr<NPObjectStub> > & stubs) { 46 void CleanUpStubs(const std::vector<base::WeakPtr<NPObjectStub> > & stubs) {
34 for (size_t i = 0; i < stubs.size(); ++i) { 47 for (size_t i = 0; i < stubs.size(); ++i) {
35 if (stubs[i]) { 48 if (stubs[i]) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // functionality. The page URL is also not required. 171 // functionality. The page URL is also not required.
159 stubs_.push_back((new NPObjectStub( 172 stubs_.push_back((new NPObjectStub(
160 object, channel_.get(), route_id, 0, GURL()))->AsWeakPtr()); 173 object, channel_.get(), route_id, 0, GURL()))->AsWeakPtr());
161 174
162 // The NPObjectStub takes a reference to the NPObject. Release the ref added 175 // The NPObjectStub takes a reference to the NPObject. Release the ref added
163 // in CreateNPVariantParam(). 176 // in CreateNPVariantParam().
164 WebKit::WebBindings::releaseObject(object); 177 WebKit::WebBindings::releaseObject(object);
165 } 178 }
166 179
167 } // namespace content 180 } // namespace content
OLDNEW
« base/android/java_handler_thread.cc ('K') | « base/base.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698