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

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

Issue 2255493004: Synchronously disable ConnectionFilterImpl when its RPHI cleans up (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-connection-filter-race
Patch Set: . Created 4 years, 4 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
« no previous file with comments | « no previous file | content/browser/renderer_host/render_process_host_impl.cc » ('j') | 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 #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 12 matching lines...) Expand all
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/interface_ptr.h" 32 #include "mojo/public/cpp/bindings/interface_ptr.h"
33 #include "services/shell/public/cpp/interface_registry.h"
33 #include "services/shell/public/interfaces/service.mojom.h" 34 #include "services/shell/public/interfaces/service.mojom.h"
34 #include "ui/gfx/gpu_memory_buffer.h" 35 #include "ui/gfx/gpu_memory_buffer.h"
35 #include "ui/gl/gpu_switching_observer.h" 36 #include "ui/gl/gpu_switching_observer.h"
36 37
37 #if defined(OS_ANDROID) 38 #if defined(OS_ANDROID)
38 #include "content/public/browser/android/interface_registry_android.h" 39 #include "content/public/browser/android/interface_registry_android.h"
39 #endif 40 #endif
40 41
41 namespace base { 42 namespace base {
42 class CommandLine; 43 class CommandLine;
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 #endif 295 #endif
295 296
296 // The count of currently swapped out but pending RenderViews. We have 297 // The count of currently swapped out but pending RenderViews. We have
297 // started to swap these in, so the renderer process should not exit if 298 // started to swap these in, so the renderer process should not exit if
298 // this count is non-zero. 299 // this count is non-zero.
299 int32_t pending_views_; 300 int32_t pending_views_;
300 301
301 private: 302 private:
302 friend class ChildProcessLauncherBrowserTest_ChildSpawnFail_Test; 303 friend class ChildProcessLauncherBrowserTest_ChildSpawnFail_Test;
303 friend class VisitRelayingRenderProcessHost; 304 friend class VisitRelayingRenderProcessHost;
305 class ConnectionFilterController;
304 class ConnectionFilterImpl; 306 class ConnectionFilterImpl;
305 307
306 std::unique_ptr<IPC::ChannelProxy> CreateChannelProxy( 308 std::unique_ptr<IPC::ChannelProxy> CreateChannelProxy(
307 const std::string& channel_id); 309 const std::string& channel_id);
308 310
309 // Creates and adds the IO thread message filters. 311 // Creates and adds the IO thread message filters.
310 void CreateMessageFilters(); 312 void CreateMessageFilters();
311 313
312 // Registers Mojo interfaces to be exposed to the renderer. 314 // Registers Mojo interfaces to be exposed to the renderer.
313 void RegisterMojoInterfaces(); 315 void RegisterMojoInterfaces();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 IPC::PlatformFileForTransit file_for_transit); 362 IPC::PlatformFileForTransit file_for_transit);
361 void SendDisableAecDumpToRenderer(); 363 void SendDisableAecDumpToRenderer();
362 base::FilePath GetAecDumpFilePathWithExtensions(const base::FilePath& file); 364 base::FilePath GetAecDumpFilePathWithExtensions(const base::FilePath& file);
363 #endif 365 #endif
364 366
365 static void OnMojoError( 367 static void OnMojoError(
366 base::WeakPtr<RenderProcessHostImpl> process, 368 base::WeakPtr<RenderProcessHostImpl> process,
367 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 369 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
368 const std::string& error); 370 const std::string& error);
369 371
372 template <typename InterfaceType>
373 using AddInterfaceCallback =
374 base::Callback<void(mojo::InterfaceRequest<InterfaceType>)>;
375
376 template <typename CallbackType>
377 struct InterfaceGetter;
378
379 template <typename InterfaceType>
380 struct InterfaceGetter<AddInterfaceCallback<InterfaceType>> {
381 static void GetInterfaceOnUIThread(
382 base::WeakPtr<RenderProcessHostImpl> weak_host,
383 const AddInterfaceCallback<InterfaceType>& callback,
384 mojo::InterfaceRequest<InterfaceType> request) {
385 if (!weak_host)
386 return;
387 callback.Run(std::move(request));
388 }
389 };
390
391 // Helper to bind an interface callback whose lifetime is limited to that of
392 // the render process currently hosted by the RPHI. Callbacks added by this
393 // method will never run beyond the next invocation of Cleanup().
394 template <typename CallbackType>
395 void AddUIThreadInterface(shell::InterfaceRegistry* registry,
396 const CallbackType& callback) {
397 registry->AddInterface(
398 base::Bind(&InterfaceGetter<CallbackType>::GetInterfaceOnUIThread,
399 instance_weak_factory_->GetWeakPtr(), callback),
400 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI));
401 }
402
370 std::string child_token_; 403 std::string child_token_;
371 404
372 std::unique_ptr<MojoChildConnection> mojo_child_connection_; 405 std::unique_ptr<MojoChildConnection> mojo_child_connection_;
373 int connection_filter_ = MojoShellConnection::kInvalidConnectionFilterId; 406 int connection_filter_id_ = MojoShellConnection::kInvalidConnectionFilterId;
407 scoped_refptr<ConnectionFilterController> connection_filter_controller_;
374 shell::mojom::ServicePtr test_service_; 408 shell::mojom::ServicePtr test_service_;
375 #if defined(OS_ANDROID) 409 #if defined(OS_ANDROID)
376 std::unique_ptr<InterfaceRegistryAndroid> interface_registry_android_; 410 std::unique_ptr<InterfaceRegistryAndroid> interface_registry_android_;
377 #endif 411 #endif
378 412
379 // The registered IPC listener objects. When this list is empty, we should 413 // The registered IPC listener objects. When this list is empty, we should
380 // delete ourselves. 414 // delete ourselves.
381 IDMap<IPC::Listener> listeners_; 415 IDMap<IPC::Listener> listeners_;
382 416
383 // The count of currently visible widgets. Since the host can be a container 417 // The count of currently visible widgets. Since the host can be a container
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 // UI thread is the source of sync IPCs and all shutdown signals. 554 // UI thread is the source of sync IPCs and all shutdown signals.
521 // Therefore a proper shutdown event to unblock the UI thread is not 555 // Therefore a proper shutdown event to unblock the UI thread is not
522 // possible without massive refactoring shutdown code. 556 // possible without massive refactoring shutdown code.
523 // Luckily Android never performs a clean shutdown. So explicitly 557 // Luckily Android never performs a clean shutdown. So explicitly
524 // ignore this problem. 558 // ignore this problem.
525 base::WaitableEvent never_signaled_; 559 base::WaitableEvent never_signaled_;
526 #endif 560 #endif
527 561
528 scoped_refptr<ResourceMessageFilter> resource_message_filter_; 562 scoped_refptr<ResourceMessageFilter> resource_message_filter_;
529 563
564 // A WeakPtrFactory which is reset every time Cleanup() runs. Used to vend
565 // WeakPtrs which are invalidated any time the RPHI is recycled.
566 std::unique_ptr<base::WeakPtrFactory<RenderProcessHostImpl>>
567 instance_weak_factory_;
568
530 base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_; 569 base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_;
531 570
532 DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl); 571 DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl);
533 }; 572 };
534 573
535 } // namespace content 574 } // namespace content
536 575
537 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ 576 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698