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

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

Issue 206923002: Adds plumbing to pass WebUI mojo::Handle from browser to renderer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add TODO and merge to trunk Created 6 years, 9 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 // Represents the browser side of the browser <--> renderer communication 5 // Represents the browser side of the browser <--> renderer communication
6 // channel. There will be one RenderProcessHost per renderer process. 6 // channel. There will be one RenderProcessHost per renderer process.
7 7
8 #include "content/browser/renderer_host/render_process_host_impl.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 #endif 154 #endif
155 155
156 #if defined(ENABLE_WEBRTC) 156 #if defined(ENABLE_WEBRTC)
157 #include "content/browser/media/webrtc_internals.h" 157 #include "content/browser/media/webrtc_internals.h"
158 #include "content/browser/renderer_host/media/media_stream_track_metrics_host.h" 158 #include "content/browser/renderer_host/media/media_stream_track_metrics_host.h"
159 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" 159 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h"
160 #include "content/common/media/media_stream_messages.h" 160 #include "content/common/media/media_stream_messages.h"
161 #endif 161 #endif
162 162
163 #if defined(USE_MOJO) 163 #if defined(USE_MOJO)
164 #include "content/common/mojo/mojo_channel_init.h" 164 #include "content/browser/renderer_host/render_process_host_mojo_impl.h"
165 #include "content/common/mojo/mojo_messages.h"
166 #include "mojo/embedder/platform_channel_pair.h"
167 #endif 165 #endif
168 166
169 extern bool g_exited_main_message_loop; 167 extern bool g_exited_main_message_loop;
170 168
171 static const char* kSiteProcessMapKeyName = "content_site_process_map"; 169 static const char* kSiteProcessMapKeyName = "content_site_process_map";
172 170
173 namespace content { 171 namespace content {
174 namespace { 172 namespace {
175 173
176 void CacheShaderInfo(int32 id, base::FilePath path) { 174 void CacheShaderInfo(int32 id, base::FilePath path) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 return ipc_fd_; 322 return ipc_fd_;
325 } 323 }
326 #endif // OS_WIN 324 #endif // OS_WIN
327 325
328 private: 326 private:
329 #if defined(OS_POSIX) 327 #if defined(OS_POSIX)
330 int ipc_fd_; 328 int ipc_fd_;
331 #endif // OS_POSIX 329 #endif // OS_POSIX
332 }; 330 };
333 331
334 #if defined(USE_MOJO)
335 base::PlatformFile PlatformFileFromScopedPlatformHandle(
336 mojo::embedder::ScopedPlatformHandle handle) {
337 #if defined(OS_POSIX)
338 return handle.release().fd;
339 #elif defined(OS_WIN)
340 return handle.release().handle;
341 #endif
342 }
343 #endif
344
345 } // namespace 332 } // namespace
346 333
347 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; 334 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL;
348 335
349 void RenderProcessHost::RegisterRendererMainThreadFactory( 336 void RenderProcessHost::RegisterRendererMainThreadFactory(
350 RendererMainThreadFactoryFunction create) { 337 RendererMainThreadFactoryFunction create) {
351 g_renderer_main_thread_factory = create; 338 g_renderer_main_thread_factory = create;
352 } 339 }
353 340
354 base::MessageLoop* g_in_process_thread; 341 base::MessageLoop* g_in_process_thread;
(...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1935 while (!iter.IsAtEnd()) { 1922 while (!iter.IsAtEnd()) {
1936 iter.GetCurrentValue()->OnMessageReceived( 1923 iter.GetCurrentValue()->OnMessageReceived(
1937 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), 1924 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(),
1938 static_cast<int>(status), 1925 static_cast<int>(status),
1939 exit_code)); 1926 exit_code));
1940 iter.Advance(); 1927 iter.Advance();
1941 } 1928 }
1942 1929
1943 ClearTransportDIBCache(); 1930 ClearTransportDIBCache();
1944 1931
1932 #if defined(USE_MOJO)
1933 render_process_host_mojo_.reset();
1934 #endif
1935
1945 // It's possible that one of the calls out to the observers might have caused 1936 // It's possible that one of the calls out to the observers might have caused
1946 // this object to be no longer needed. 1937 // this object to be no longer needed.
1947 if (delayed_cleanup_needed_) 1938 if (delayed_cleanup_needed_)
1948 Cleanup(); 1939 Cleanup();
1949 1940
1950 // This object is not deleted at this point and might be reused later. 1941 // This object is not deleted at this point and might be reused later.
1951 // TODO(darin): clean this up 1942 // TODO(darin): clean this up
1952 } 1943 }
1953 1944
1954 int RenderProcessHostImpl::GetActiveViewCount() { 1945 int RenderProcessHostImpl::GetActiveViewCount() {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 2068
2078 while (!queued_messages_.empty()) { 2069 while (!queued_messages_.empty()) {
2079 Send(queued_messages_.front()); 2070 Send(queued_messages_.front());
2080 queued_messages_.pop(); 2071 queued_messages_.pop();
2081 } 2072 }
2082 2073
2083 #if defined(ENABLE_WEBRTC) 2074 #if defined(ENABLE_WEBRTC)
2084 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) 2075 if (WebRTCInternals::GetInstance()->aec_dump_enabled())
2085 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); 2076 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path());
2086 #endif 2077 #endif
2078
2079 #if defined(USE_MOJO)
2080 if (render_process_host_mojo_.get())
2081 render_process_host_mojo_->OnProcessLaunched();
2082 #endif
2087 } 2083 }
2088 2084
2089 scoped_refptr<AudioRendererHost> 2085 scoped_refptr<AudioRendererHost>
2090 RenderProcessHostImpl::audio_renderer_host() const { 2086 RenderProcessHostImpl::audio_renderer_host() const {
2091 return audio_renderer_host_; 2087 return audio_renderer_host_;
2092 } 2088 }
2093 2089
2094 void RenderProcessHostImpl::OnUserMetricsRecordAction( 2090 void RenderProcessHostImpl::OnUserMetricsRecordAction(
2095 const std::string& action) { 2091 const std::string& action) {
2096 RecordComputedAction(action); 2092 RecordComputedAction(action);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2151 2147
2152 void RenderProcessHostImpl::DecrementWorkerRefCount() { 2148 void RenderProcessHostImpl::DecrementWorkerRefCount() {
2153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2154 DCHECK_GT(worker_ref_count_, 0); 2150 DCHECK_GT(worker_ref_count_, 0);
2155 --worker_ref_count_; 2151 --worker_ref_count_;
2156 if (worker_ref_count_ == 0) 2152 if (worker_ref_count_ == 0)
2157 Cleanup(); 2153 Cleanup();
2158 } 2154 }
2159 2155
2160 #if defined(USE_MOJO) 2156 #if defined(USE_MOJO)
2161 void RenderProcessHostImpl::CreateMojoChannel() { 2157 void RenderProcessHostImpl::SetWebUIHandle(
2162 if (mojo_channel_init_.get()) 2158 int32 view_routing_id,
2163 return; 2159 mojo::ScopedMessagePipeHandle handle) {
2164 2160 if (!render_process_host_mojo_)
2165 mojo::embedder::PlatformChannelPair channel_pair; 2161 render_process_host_mojo_.reset(new RenderProcessHostMojoImpl(this));
2166 mojo_channel_init_.reset(new MojoChannelInit); 2162 render_process_host_mojo_->SetWebUIHandle(view_routing_id, handle.Pass());
2167 mojo_channel_init_->Init(
2168 PlatformFileFromScopedPlatformHandle(channel_pair.PassServerHandle()),
2169 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
2170 if (mojo_channel_init_->is_handle_valid()) {
2171 base::ProcessHandle process_handle = run_renderer_in_process() ?
2172 base::Process::Current().handle() :
2173 child_process_launcher_->GetHandle();
2174 base::PlatformFile client_file =
2175 PlatformFileFromScopedPlatformHandle(channel_pair.PassClientHandle());
2176 Send(new MojoMsg_ChannelCreated(
2177 IPC::GetFileHandleForProcess(client_file, process_handle, true)));
2178 }
2179 } 2163 }
2180 #endif 2164 #endif
2181 2165
2182 } // namespace content 2166 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698