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

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: merge 2 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 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 while (!iter.IsAtEnd()) { 1921 while (!iter.IsAtEnd()) {
1935 iter.GetCurrentValue()->OnMessageReceived( 1922 iter.GetCurrentValue()->OnMessageReceived(
1936 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), 1923 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(),
1937 static_cast<int>(status), 1924 static_cast<int>(status),
1938 exit_code)); 1925 exit_code));
1939 iter.Advance(); 1926 iter.Advance();
1940 } 1927 }
1941 1928
1942 ClearTransportDIBCache(); 1929 ClearTransportDIBCache();
1943 1930
1931 #if defined(USE_MOJO)
1932 render_process_host_mojo_.reset();
1933 #endif
1934
1944 // It's possible that one of the calls out to the observers might have caused 1935 // It's possible that one of the calls out to the observers might have caused
1945 // this object to be no longer needed. 1936 // this object to be no longer needed.
1946 if (delayed_cleanup_needed_) 1937 if (delayed_cleanup_needed_)
1947 Cleanup(); 1938 Cleanup();
1948 1939
1949 // This object is not deleted at this point and might be reused later. 1940 // This object is not deleted at this point and might be reused later.
1950 // TODO(darin): clean this up 1941 // TODO(darin): clean this up
1951 } 1942 }
1952 1943
1953 int RenderProcessHostImpl::GetActiveViewCount() { 1944 int RenderProcessHostImpl::GetActiveViewCount() {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 2067
2077 while (!queued_messages_.empty()) { 2068 while (!queued_messages_.empty()) {
2078 Send(queued_messages_.front()); 2069 Send(queued_messages_.front());
2079 queued_messages_.pop(); 2070 queued_messages_.pop();
2080 } 2071 }
2081 2072
2082 #if defined(ENABLE_WEBRTC) 2073 #if defined(ENABLE_WEBRTC)
2083 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) 2074 if (WebRTCInternals::GetInstance()->aec_dump_enabled())
2084 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path()); 2075 EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path());
2085 #endif 2076 #endif
2077
2078 #if defined(USE_MOJO)
2079 if (render_process_host_mojo_.get())
2080 render_process_host_mojo_->OnProcessLaunched();
2081 #endif
2086 } 2082 }
2087 2083
2088 scoped_refptr<AudioRendererHost> 2084 scoped_refptr<AudioRendererHost>
2089 RenderProcessHostImpl::audio_renderer_host() const { 2085 RenderProcessHostImpl::audio_renderer_host() const {
2090 return audio_renderer_host_; 2086 return audio_renderer_host_;
2091 } 2087 }
2092 2088
2093 void RenderProcessHostImpl::OnUserMetricsRecordAction( 2089 void RenderProcessHostImpl::OnUserMetricsRecordAction(
2094 const std::string& action) { 2090 const std::string& action) {
2095 RecordComputedAction(action); 2091 RecordComputedAction(action);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2150 2146
2151 void RenderProcessHostImpl::DecrementWorkerRefCount() { 2147 void RenderProcessHostImpl::DecrementWorkerRefCount() {
2152 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2153 DCHECK_GT(worker_ref_count_, 0); 2149 DCHECK_GT(worker_ref_count_, 0);
2154 --worker_ref_count_; 2150 --worker_ref_count_;
2155 if (worker_ref_count_ == 0) 2151 if (worker_ref_count_ == 0)
2156 Cleanup(); 2152 Cleanup();
2157 } 2153 }
2158 2154
2159 #if defined(USE_MOJO) 2155 #if defined(USE_MOJO)
2160 void RenderProcessHostImpl::CreateMojoChannel() { 2156 void RenderProcessHostImpl::SetWebUIHandle(int32 view_routing_id,
2161 if (mojo_channel_init_.get()) 2157 mojo::ScopedHandle handle) {
2162 return; 2158 if (!render_process_host_mojo_)
2163 2159 render_process_host_mojo_.reset(new RenderProcessHostMojoImpl(this));
2164 mojo::embedder::PlatformChannelPair channel_pair; 2160 render_process_host_mojo_->SetWebUIHandle(view_routing_id, handle.Pass());
2165 mojo_channel_init_.reset(new MojoChannelInit);
2166 mojo_channel_init_->Init(
2167 PlatformFileFromScopedPlatformHandle(channel_pair.PassServerHandle()),
2168 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
2169 if (mojo_channel_init_->is_handle_valid()) {
2170 base::ProcessHandle process_handle = run_renderer_in_process() ?
2171 base::Process::Current().handle() :
2172 child_process_launcher_->GetHandle();
2173 base::PlatformFile client_file =
2174 PlatformFileFromScopedPlatformHandle(channel_pair.PassClientHandle());
2175 Send(new MojoMsg_ChannelCreated(
2176 IPC::GetFileHandleForProcess(client_file, process_handle, true)));
2177 }
2178 } 2161 }
2179 #endif 2162 #endif
2180 2163
2181 } // namespace content 2164 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698