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

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

Issue 2383853003: Move FrameMsg_NewFrame/NewFrameProxy to mojom (Closed)
Patch Set: . Created 4 years, 2 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 #include "gpu/command_buffer/service/gpu_switches.h" 168 #include "gpu/command_buffer/service/gpu_switches.h"
169 #include "ipc/attachment_broker.h" 169 #include "ipc/attachment_broker.h"
170 #include "ipc/attachment_broker_privileged.h" 170 #include "ipc/attachment_broker_privileged.h"
171 #include "ipc/ipc.mojom.h" 171 #include "ipc/ipc.mojom.h"
172 #include "ipc/ipc_channel.h" 172 #include "ipc/ipc_channel.h"
173 #include "ipc/ipc_channel_mojo.h" 173 #include "ipc/ipc_channel_mojo.h"
174 #include "ipc/ipc_logging.h" 174 #include "ipc/ipc_logging.h"
175 #include "ipc/ipc_switches.h" 175 #include "ipc/ipc_switches.h"
176 #include "media/base/media_switches.h" 176 #include "media/base/media_switches.h"
177 #include "mojo/edk/embedder/embedder.h" 177 #include "mojo/edk/embedder/embedder.h"
178 #include "mojo/public/cpp/bindings/associated_interface_ptr.h"
178 #include "net/url_request/url_request_context_getter.h" 179 #include "net/url_request/url_request_context_getter.h"
179 #include "ppapi/shared_impl/ppapi_switches.h" 180 #include "ppapi/shared_impl/ppapi_switches.h"
180 #include "services/shell/public/cpp/connection.h" 181 #include "services/shell/public/cpp/connection.h"
181 #include "services/shell/public/cpp/interface_provider.h" 182 #include "services/shell/public/cpp/interface_provider.h"
182 #include "services/shell/public/cpp/interface_registry.h" 183 #include "services/shell/public/cpp/interface_registry.h"
183 #include "services/shell/runner/common/switches.h" 184 #include "services/shell/runner/common/switches.h"
184 #include "storage/browser/fileapi/sandbox_file_system_backend.h" 185 #include "storage/browser/fileapi/sandbox_file_system_backend.h"
185 #include "third_party/skia/include/core/SkBitmap.h" 186 #include "third_party/skia/include/core/SkBitmap.h"
186 #include "ui/base/ui_base_switches.h" 187 #include "ui/base/ui_base_switches.h"
187 #include "ui/display/display_switches.h" 188 #include "ui/display/display_switches.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 243
243 #if defined(OS_WIN) 244 #if defined(OS_WIN)
244 #define IntToStringType base::IntToString16 245 #define IntToStringType base::IntToString16
245 #else 246 #else
246 #define IntToStringType base::IntToString 247 #define IntToStringType base::IntToString
247 #endif 248 #endif
248 249
249 namespace content { 250 namespace content {
250 namespace { 251 namespace {
251 252
253 const char kRendererInterfaceKeyName[] = "mojom_renderer_interface";
252 const char kSiteProcessMapKeyName[] = "content_site_process_map"; 254 const char kSiteProcessMapKeyName[] = "content_site_process_map";
253 255
254 #ifdef ENABLE_WEBRTC 256 #ifdef ENABLE_WEBRTC
255 const base::FilePath::CharType kAecDumpFileNameAddition[] = 257 const base::FilePath::CharType kAecDumpFileNameAddition[] =
256 FILE_PATH_LITERAL("aec_dump"); 258 FILE_PATH_LITERAL("aec_dump");
257 #endif 259 #endif
258 260
259 void CacheShaderInfo(int32_t id, base::FilePath path) { 261 void CacheShaderInfo(int32_t id, base::FilePath path) {
260 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path); 262 ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path);
261 } 263 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 DCHECK(context); 360 DCHECK(context);
359 SiteProcessMap* map = static_cast<SiteProcessMap*>( 361 SiteProcessMap* map = static_cast<SiteProcessMap*>(
360 context->GetUserData(kSiteProcessMapKeyName)); 362 context->GetUserData(kSiteProcessMapKeyName));
361 if (!map) { 363 if (!map) {
362 map = new SiteProcessMap(); 364 map = new SiteProcessMap();
363 context->SetUserData(kSiteProcessMapKeyName, map); 365 context->SetUserData(kSiteProcessMapKeyName, map);
364 } 366 }
365 return map; 367 return map;
366 } 368 }
367 369
370 // Holds a Mojo associated interface proxy in an RPH's user data.
371 template <typename Interface>
372 class AssociatedInterfaceHolder : public base::SupportsUserData::Data {
373 public:
374 AssociatedInterfaceHolder() {}
375 ~AssociatedInterfaceHolder() override {}
376
377 mojo::AssociatedInterfacePtr<Interface>& proxy() { return proxy_; }
378
379 private:
380 mojo::AssociatedInterfacePtr<Interface> proxy_;
381
382 DISALLOW_COPY_AND_ASSIGN(AssociatedInterfaceHolder);
383 };
384
368 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) 385 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
369 // This static member variable holds the zygote communication information for 386 // This static member variable holds the zygote communication information for
370 // the renderer. 387 // the renderer.
371 ZygoteHandle g_render_zygote; 388 ZygoteHandle g_render_zygote;
372 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) 389 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
373 390
374 // NOTE: changes to this class need to be reviewed by the security team. 391 // NOTE: changes to this class need to be reviewed by the security team.
375 class RendererSandboxedProcessLauncherDelegate 392 class RendererSandboxedProcessLauncherDelegate
376 : public SandboxedProcessLauncherDelegate { 393 : public SandboxedProcessLauncherDelegate {
377 public: 394 public:
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 848
832 bool RenderProcessHostImpl::Init() { 849 bool RenderProcessHostImpl::Init() {
833 // calling Init() more than once does nothing, this makes it more convenient 850 // calling Init() more than once does nothing, this makes it more convenient
834 // for the view host which may not be sure in some cases 851 // for the view host which may not be sure in some cases
835 if (channel_) 852 if (channel_)
836 return true; 853 return true;
837 854
838 // Ensure that the remote associated interfaces are re-initialized on next 855 // Ensure that the remote associated interfaces are re-initialized on next
839 // access since they're associated with a specific Channel instance. 856 // access since they're associated with a specific Channel instance.
840 remote_route_provider_.reset(); 857 remote_route_provider_.reset();
841 renderer_interface_.reset(); 858 RemoveUserData(kRendererInterfaceKeyName);
842 859
843 base::CommandLine::StringType renderer_prefix; 860 base::CommandLine::StringType renderer_prefix;
844 // A command prefix is something prepended to the command line of the spawned 861 // A command prefix is something prepended to the command line of the spawned
845 // process. 862 // process.
846 const base::CommandLine& browser_command_line = 863 const base::CommandLine& browser_command_line =
847 *base::CommandLine::ForCurrentProcess(); 864 *base::CommandLine::ForCurrentProcess();
848 renderer_prefix = 865 renderer_prefix =
849 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); 866 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix);
850 867
851 #if defined(OS_LINUX) 868 #if defined(OS_LINUX)
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 } 1404 }
1388 1405
1389 mojom::RouteProvider* RenderProcessHostImpl::GetRemoteRouteProvider() { 1406 mojom::RouteProvider* RenderProcessHostImpl::GetRemoteRouteProvider() {
1390 if (!remote_route_provider_) { 1407 if (!remote_route_provider_) {
1391 DCHECK(channel_); 1408 DCHECK(channel_);
1392 channel_->GetRemoteAssociatedInterface(&remote_route_provider_); 1409 channel_->GetRemoteAssociatedInterface(&remote_route_provider_);
1393 } 1410 }
1394 return remote_route_provider_.get(); 1411 return remote_route_provider_.get();
1395 } 1412 }
1396 1413
1397 mojom::Renderer* RenderProcessHostImpl::GetRendererInterface() { 1414 // static
1398 if (!renderer_interface_) { 1415 mojom::Renderer* RenderProcessHostImpl::GetRendererInterface(
1399 DCHECK(channel_); 1416 RenderProcessHost* host) {
1400 channel_->GetRemoteAssociatedInterface(&renderer_interface_); 1417 AssociatedInterfaceHolder<mojom::Renderer>* holder =
1418 static_cast<AssociatedInterfaceHolder<mojom::Renderer>*>(
1419 host->GetUserData(kRendererInterfaceKeyName));
1420 if (!holder) {
1421 holder = new AssociatedInterfaceHolder<mojom::Renderer>;
1422
1423 // Takes ownership of |holder|.
1424 host->SetUserData(kRendererInterfaceKeyName, holder);
1425
1426 // In tests, GetChannel() is null. We bind the proxy to a dead-end endpoint
1427 // so that its outgoing requests are be silently dropped.
1428 IPC::ChannelProxy* channel = host->GetChannel();
1429 if (channel)
1430 channel->GetRemoteAssociatedInterface(&holder->proxy());
1431 else
1432 mojo::GetDummyProxyForTesting(&holder->proxy());
1401 } 1433 }
1402 return renderer_interface_.get(); 1434
1435 return holder->proxy().get();
1403 } 1436 }
1404 1437
1405 void RenderProcessHostImpl::AddRoute(int32_t routing_id, 1438 void RenderProcessHostImpl::AddRoute(int32_t routing_id,
1406 IPC::Listener* listener) { 1439 IPC::Listener* listener) {
1407 CHECK(!listeners_.Lookup(routing_id)) << "Found Routing ID Conflict: " 1440 CHECK(!listeners_.Lookup(routing_id)) << "Found Routing ID Conflict: "
1408 << routing_id; 1441 << routing_id;
1409 listeners_.AddWithID(listener, routing_id); 1442 listeners_.AddWithID(listener, routing_id);
1410 } 1443 }
1411 1444
1412 void RenderProcessHostImpl::RemoveRoute(int32_t routing_id) { 1445 void RenderProcessHostImpl::RemoveRoute(int32_t routing_id) {
(...skipping 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after
3002 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; 3035 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error;
3003 3036
3004 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias 3037 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias
3005 // enough information here so that we can determine what the bad message was. 3038 // enough information here so that we can determine what the bad message was.
3006 base::debug::Alias(&error); 3039 base::debug::Alias(&error);
3007 bad_message::ReceivedBadMessage(process.get(), 3040 bad_message::ReceivedBadMessage(process.get(),
3008 bad_message::RPH_MOJO_PROCESS_ERROR); 3041 bad_message::RPH_MOJO_PROCESS_ERROR);
3009 } 3042 }
3010 3043
3011 } // namespace content 3044 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698