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

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

Issue 2310563002: Adds routed interface support between RenderFrameHost and RenderFrame (Closed)
Patch Set: Created 4 years, 3 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 (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 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 11 matching lines...) Expand all
22 #include "build/build_config.h" 22 #include "build/build_config.h"
23 #include "content/browser/child_process_launcher.h" 23 #include "content/browser/child_process_launcher.h"
24 #include "content/browser/dom_storage/session_storage_namespace_impl.h" 24 #include "content/browser/dom_storage/session_storage_namespace_impl.h"
25 #include "content/browser/power_monitor_message_broadcaster.h" 25 #include "content/browser/power_monitor_message_broadcaster.h"
26 #include "content/browser/webrtc/webrtc_eventlog_host.h" 26 #include "content/browser/webrtc/webrtc_eventlog_host.h"
27 #include "content/common/content_export.h" 27 #include "content/common/content_export.h"
28 #include "content/public/browser/render_process_host.h" 28 #include "content/public/browser/render_process_host.h"
29 #include "content/public/common/mojo_shell_connection.h" 29 #include "content/public/common/mojo_shell_connection.h"
30 #include "ipc/ipc_channel_proxy.h" 30 #include "ipc/ipc_channel_proxy.h"
31 #include "ipc/ipc_platform_file.h" 31 #include "ipc/ipc_platform_file.h"
32 #include "mojo/public/cpp/bindings/associated_binding.h"
33 #include "mojo/public/cpp/bindings/associated_binding_set.h"
32 #include "mojo/public/cpp/bindings/interface_ptr.h" 34 #include "mojo/public/cpp/bindings/interface_ptr.h"
33 #include "services/shell/public/cpp/interface_registry.h" 35 #include "services/shell/public/cpp/interface_registry.h"
34 #include "services/shell/public/interfaces/service.mojom.h" 36 #include "services/shell/public/interfaces/service.mojom.h"
35 #include "ui/gfx/gpu_memory_buffer.h" 37 #include "ui/gfx/gpu_memory_buffer.h"
36 #include "ui/gl/gpu_switching_observer.h" 38 #include "ui/gl/gpu_switching_observer.h"
37 39
38 #if defined(OS_ANDROID) 40 #if defined(OS_ANDROID)
39 #include "content/public/browser/android/interface_registry_android.h" 41 #include "content/public/browser/android/interface_registry_android.h"
40 #endif 42 #endif
41 43
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // are correlated with IDs. This way, the Views and the corresponding ViewHosts 101 // are correlated with IDs. This way, the Views and the corresponding ViewHosts
100 // communicate through the two process objects. 102 // communicate through the two process objects.
101 // 103 //
102 // A RenderProcessHost is also associated with one and only one 104 // A RenderProcessHost is also associated with one and only one
103 // StoragePartition. This allows us to implement strong storage isolation 105 // StoragePartition. This allows us to implement strong storage isolation
104 // because all the IPCs from the RenderViews (renderer) will only ever be able 106 // because all the IPCs from the RenderViews (renderer) will only ever be able
105 // to access the partition they are assigned to. 107 // to access the partition they are assigned to.
106 class CONTENT_EXPORT RenderProcessHostImpl 108 class CONTENT_EXPORT RenderProcessHostImpl
107 : public RenderProcessHost, 109 : public RenderProcessHost,
108 public ChildProcessLauncher::Client, 110 public ChildProcessLauncher::Client,
109 public ui::GpuSwitchingObserver { 111 public ui::GpuSwitchingObserver,
112 public NON_EXPORTED_BASE(mojom::RouteProvider) {
110 public: 113 public:
111 RenderProcessHostImpl(BrowserContext* browser_context, 114 RenderProcessHostImpl(BrowserContext* browser_context,
112 StoragePartitionImpl* storage_partition_impl, 115 StoragePartitionImpl* storage_partition_impl,
113 bool is_for_guests_only); 116 bool is_for_guests_only);
114 ~RenderProcessHostImpl() override; 117 ~RenderProcessHostImpl() override;
115 118
116 // RenderProcessHost implementation (public portion). 119 // RenderProcessHost implementation (public portion).
117 void EnableSendQueue() override; 120 void EnableSendQueue() override;
118 bool Init() override; 121 bool Init() override;
119 int GetNextRoutingID() override; 122 int GetNextRoutingID() override;
120 void AddRoute(int32_t routing_id, IPC::Listener* listener) override; 123 void AddRoute(int32_t routing_id, IPC::Listener* listener) override;
121 void RemoveRoute(int32_t routing_id) override; 124 void RemoveRoute(int32_t routing_id) override;
125 void AddRoutedInterfaces(int32_t routing_id,
126 mojom::RoutedInterfaceProvider* provider) override;
127 mojo::AssociatedGroup* GetRoutedInterfaceGroup() override;
122 void AddObserver(RenderProcessHostObserver* observer) override; 128 void AddObserver(RenderProcessHostObserver* observer) override;
123 void RemoveObserver(RenderProcessHostObserver* observer) override; 129 void RemoveObserver(RenderProcessHostObserver* observer) override;
124 void ShutdownForBadMessage() override; 130 void ShutdownForBadMessage() override;
125 void WidgetRestored() override; 131 void WidgetRestored() override;
126 void WidgetHidden() override; 132 void WidgetHidden() override;
127 int VisibleWidgetCount() const override; 133 int VisibleWidgetCount() const override;
128 void AudioStateChanged() override; 134 void AudioStateChanged() override;
129 bool IsForGuestsOnly() const override; 135 bool IsForGuestsOnly() const override;
130 StoragePartition* GetStoragePartition() const override; 136 StoragePartition* GetStoragePartition() const override;
131 bool Shutdown(int exit_code, bool wait) override; 137 bool Shutdown(int exit_code, bool wait) override;
(...skipping 26 matching lines...) Expand all
158 base::Callback<void(const std::string&)> callback) override; 164 base::Callback<void(const std::string&)> callback) override;
159 void ClearWebRtcLogMessageCallback() override; 165 void ClearWebRtcLogMessageCallback() override;
160 WebRtcStopRtpDumpCallback StartRtpDump( 166 WebRtcStopRtpDumpCallback StartRtpDump(
161 bool incoming, 167 bool incoming,
162 bool outgoing, 168 bool outgoing,
163 const WebRtcRtpPacketCallback& packet_callback) override; 169 const WebRtcRtpPacketCallback& packet_callback) override;
164 #endif 170 #endif
165 void ResumeDeferredNavigation(const GlobalRequestID& request_id) override; 171 void ResumeDeferredNavigation(const GlobalRequestID& request_id) override;
166 void NotifyTimezoneChange(const std::string& timezone) override; 172 void NotifyTimezoneChange(const std::string& timezone) override;
167 shell::InterfaceProvider* GetRemoteInterfaces() override; 173 shell::InterfaceProvider* GetRemoteInterfaces() override;
174 mojom::RouteProvider* GetRemoteRouteProvider() override;
168 std::unique_ptr<base::SharedPersistentMemoryAllocator> TakeMetricsAllocator() 175 std::unique_ptr<base::SharedPersistentMemoryAllocator> TakeMetricsAllocator()
169 override; 176 override;
170 const base::TimeTicks& GetInitTimeForNavigationMetrics() const override; 177 const base::TimeTicks& GetInitTimeForNavigationMetrics() const override;
171 #if defined(ENABLE_BROWSER_CDMS) 178 #if defined(ENABLE_BROWSER_CDMS)
172 scoped_refptr<media::MediaKeys> GetCdm(int render_frame_id, 179 scoped_refptr<media::MediaKeys> GetCdm(int render_frame_id,
173 int cdm_id) const override; 180 int cdm_id) const override;
174 #endif 181 #endif
175 bool IsProcessBackgrounded() const override; 182 bool IsProcessBackgrounded() const override;
176 void IncrementWorkerRefCount() override; 183 void IncrementWorkerRefCount() override;
177 void DecrementWorkerRefCount() override; 184 void DecrementWorkerRefCount() override;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 321
315 std::unique_ptr<IPC::ChannelProxy> CreateChannelProxy( 322 std::unique_ptr<IPC::ChannelProxy> CreateChannelProxy(
316 const std::string& channel_id); 323 const std::string& channel_id);
317 324
318 // Creates and adds the IO thread message filters. 325 // Creates and adds the IO thread message filters.
319 void CreateMessageFilters(); 326 void CreateMessageFilters();
320 327
321 // Registers Mojo interfaces to be exposed to the renderer. 328 // Registers Mojo interfaces to be exposed to the renderer.
322 void RegisterMojoInterfaces(); 329 void RegisterMojoInterfaces();
323 330
331 // mojom::RouteProvider:
332 void GetRoutedInterfaces(
333 int32_t routing_id,
334 mojom::RoutedInterfaceProviderAssociatedRequest request) override;
335
324 void CreateStoragePartitionService( 336 void CreateStoragePartitionService(
325 mojo::InterfaceRequest<mojom::StoragePartitionService> request); 337 mojo::InterfaceRequest<mojom::StoragePartitionService> request);
326 338
327 // Control message handlers. 339 // Control message handlers.
328 void OnShutdownRequest(); 340 void OnShutdownRequest();
329 void SuddenTerminationChanged(bool enabled); 341 void SuddenTerminationChanged(bool enabled);
330 void OnUserMetricsRecordAction(const std::string& action); 342 void OnUserMetricsRecordAction(const std::string& action);
331 void OnCloseACK(int old_route_id); 343 void OnCloseACK(int old_route_id);
332 344
333 // Generates a command line to be used to spawn a renderer and appends the 345 // Generates a command line to be used to spawn a renderer and appends the
(...skipping 14 matching lines...) Expand all
348 360
349 // Creates a PersistentMemoryAllocator and shares it with the renderer 361 // Creates a PersistentMemoryAllocator and shares it with the renderer
350 // process for it to store histograms from that process. The allocator is 362 // process for it to store histograms from that process. The allocator is
351 // available for extraction by a SubprocesMetricsProvider in order to 363 // available for extraction by a SubprocesMetricsProvider in order to
352 // report those histograms to UMA. 364 // report those histograms to UMA.
353 void CreateSharedRendererHistogramAllocator(); 365 void CreateSharedRendererHistogramAllocator();
354 366
355 // Handle termination of our process. 367 // Handle termination of our process.
356 void ProcessDied(bool already_dead, RendererClosedDetails* known_details); 368 void ProcessDied(bool already_dead, RendererClosedDetails* known_details);
357 369
370 void OnRouteProviderRequest(mojom::RouteProviderAssociatedRequest request);
371
358 // GpuSwitchingObserver implementation. 372 // GpuSwitchingObserver implementation.
359 void OnGpuSwitched() override; 373 void OnGpuSwitched() override;
360 374
361 #if defined(ENABLE_WEBRTC) 375 #if defined(ENABLE_WEBRTC)
362 void OnRegisterAecDumpConsumer(int id); 376 void OnRegisterAecDumpConsumer(int id);
363 void OnUnregisterAecDumpConsumer(int id); 377 void OnUnregisterAecDumpConsumer(int id);
364 void RegisterAecDumpConsumerOnUIThread(int id); 378 void RegisterAecDumpConsumerOnUIThread(int id);
365 void UnregisterAecDumpConsumerOnUIThread(int id); 379 void UnregisterAecDumpConsumerOnUIThread(int id);
366 void EnableAecDumpForId(const base::FilePath& file, int id); 380 void EnableAecDumpForId(const base::FilePath& file, int id);
367 // Sends |file_for_transit| to the render process. 381 // Sends |file_for_transit| to the render process.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 scoped_refptr<ConnectionFilterController> connection_filter_controller_; 428 scoped_refptr<ConnectionFilterController> connection_filter_controller_;
415 shell::mojom::ServicePtr test_service_; 429 shell::mojom::ServicePtr test_service_;
416 #if defined(OS_ANDROID) 430 #if defined(OS_ANDROID)
417 std::unique_ptr<InterfaceRegistryAndroid> interface_registry_android_; 431 std::unique_ptr<InterfaceRegistryAndroid> interface_registry_android_;
418 #endif 432 #endif
419 433
420 // The registered IPC listener objects. When this list is empty, we should 434 // The registered IPC listener objects. When this list is empty, we should
421 // delete ourselves. 435 // delete ourselves.
422 IDMap<IPC::Listener> listeners_; 436 IDMap<IPC::Listener> listeners_;
423 437
438 // Registered routed interface providers. These are not owned.
439 std::map<int32_t, mojom::RoutedInterfaceProvider*>
440 routed_interface_providers_;
441
442 mojo::AssociatedBinding<mojom::RouteProvider> route_provider_binding_;
443 mojo::AssociatedBindingSet<mojom::RoutedInterfaceProvider>
444 routed_interface_provider_bindings_;
445
424 // The count of currently visible widgets. Since the host can be a container 446 // The count of currently visible widgets. Since the host can be a container
425 // for multiple widgets, it uses this count to determine when it should be 447 // for multiple widgets, it uses this count to determine when it should be
426 // backgrounded. 448 // backgrounded.
427 int32_t visible_widgets_; 449 int32_t visible_widgets_;
428 450
429 // Whether this process currently has backgrounded priority. Tracked so that 451 // Whether this process currently has backgrounded priority. Tracked so that
430 // UpdateProcessPriority() can avoid redundantly setting the priority. 452 // UpdateProcessPriority() can avoid redundantly setting the priority.
431 bool is_process_backgrounded_; 453 bool is_process_backgrounded_;
432 454
433 // Used to allow a RenderWidgetHost to intercept various messages on the 455 // Used to allow a RenderWidgetHost to intercept various messages on the
(...skipping 16 matching lines...) Expand all
450 // also reset that in the case of process termination. 472 // also reset that in the case of process termination.
451 bool is_initialized_; 473 bool is_initialized_;
452 474
453 // PlzNavigate 475 // PlzNavigate
454 // Stores the time at which the first call to Init happened. 476 // Stores the time at which the first call to Init happened.
455 base::TimeTicks init_time_; 477 base::TimeTicks init_time_;
456 478
457 // Used to launch and terminate the process without blocking the UI thread. 479 // Used to launch and terminate the process without blocking the UI thread.
458 std::unique_ptr<ChildProcessLauncher> child_process_launcher_; 480 std::unique_ptr<ChildProcessLauncher> child_process_launcher_;
459 481
460 // Messages we queue while waiting for the process handle. We queue them here 482 // Messages we queue before the ChannelProxy is created.
461 // instead of in the channel so that we ensure they're sent after init related 483 std::queue<std::unique_ptr<IPC::Message>> queued_messages_;
462 // messages that are sent once the process handle is available. This is
463 // because the queued messages may have dependencies on the init messages.
464 std::queue<IPC::Message*> queued_messages_;
465 484
466 // The globally-unique identifier for this RPH. 485 // The globally-unique identifier for this RPH.
467 const int id_; 486 const int id_;
468 487
469 // A secondary ID used by the Mojo shell to distinguish different incarnations 488 // A secondary ID used by the Mojo shell to distinguish different incarnations
470 // of the same RPH from each other. Unlike |id_| this is not globally unique, 489 // of the same RPH from each other. Unlike |id_| this is not globally unique,
471 // but it is guaranteed to change every time Init() is called. 490 // but it is guaranteed to change every time Init() is called.
472 int instance_id_ = 1; 491 int instance_id_ = 1;
473 492
474 BrowserContext* browser_context_; 493 BrowserContext* browser_context_;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 // UI thread is the source of sync IPCs and all shutdown signals. 580 // UI thread is the source of sync IPCs and all shutdown signals.
562 // Therefore a proper shutdown event to unblock the UI thread is not 581 // Therefore a proper shutdown event to unblock the UI thread is not
563 // possible without massive refactoring shutdown code. 582 // possible without massive refactoring shutdown code.
564 // Luckily Android never performs a clean shutdown. So explicitly 583 // Luckily Android never performs a clean shutdown. So explicitly
565 // ignore this problem. 584 // ignore this problem.
566 base::WaitableEvent never_signaled_; 585 base::WaitableEvent never_signaled_;
567 #endif 586 #endif
568 587
569 scoped_refptr<ResourceMessageFilter> resource_message_filter_; 588 scoped_refptr<ResourceMessageFilter> resource_message_filter_;
570 589
590 mojom::RouteProviderAssociatedPtr remote_route_provider_;
591
571 // A WeakPtrFactory which is reset every time Cleanup() runs. Used to vend 592 // A WeakPtrFactory which is reset every time Cleanup() runs. Used to vend
572 // WeakPtrs which are invalidated any time the RPHI is recycled. 593 // WeakPtrs which are invalidated any time the RPHI is recycled.
573 std::unique_ptr<base::WeakPtrFactory<RenderProcessHostImpl>> 594 std::unique_ptr<base::WeakPtrFactory<RenderProcessHostImpl>>
574 instance_weak_factory_; 595 instance_weak_factory_;
575 596
576 base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_; 597 base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_;
577 598
578 DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl); 599 DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl);
579 }; 600 };
580 601
581 } // namespace content 602 } // namespace content
582 603
583 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ 604 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698