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

Side by Side Diff: chrome/renderer/chrome_render_thread_observer.h

Issue 2642263002: Convert ChromeViewMsg_SetFieldTrialGroup to use mojo. (Closed)
Patch Set: Convert ChromeViewMsg_SetFieldTrialGroup to use mojo. Created 3 years, 11 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 CHROME_RENDERER_CHROME_RENDER_THREAD_OBSERVER_H_ 5 #ifndef CHROME_RENDERER_CHROME_RENDER_THREAD_OBSERVER_H_
6 #define CHROME_RENDERER_CHROME_RENDER_THREAD_OBSERVER_H_ 6 #define CHROME_RENDERER_CHROME_RENDER_THREAD_OBSERVER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "chrome/common/field_trial.mojom.h"
15 #include "chrome/common/renderer_configuration.mojom.h" 16 #include "chrome/common/renderer_configuration.mojom.h"
16 #include "components/content_settings/core/common/content_settings.h" 17 #include "components/content_settings/core/common/content_settings.h"
17 #include "components/variations/child_process_field_trial_syncer.h" 18 #include "components/variations/child_process_field_trial_syncer.h"
18 #include "content/public/renderer/render_thread_observer.h" 19 #include "content/public/renderer/render_thread_observer.h"
19 #include "mojo/public/cpp/bindings/associated_binding_set.h" 20 #include "mojo/public/cpp/bindings/associated_binding_set.h"
20 21
21 namespace content { 22 namespace content {
22 class ResourceDispatcherDelegate; 23 class ResourceDispatcherDelegate;
23 } 24 }
24 25
25 namespace visitedlink { 26 namespace visitedlink {
26 class VisitedLinkSlave; 27 class VisitedLinkSlave;
27 } 28 }
28 29
29 // This class filters the incoming control messages (i.e. ones not destined for 30 // This class filters the incoming control messages (i.e. ones not destined for
30 // a RenderView) for Chrome specific messages that the content layer doesn't 31 // a RenderView) for Chrome specific messages that the content layer doesn't
31 // happen. If a few messages are related, they should probably have their own 32 // happen. If a few messages are related, they should probably have their own
32 // observer. 33 // observer.
33 class ChromeRenderThreadObserver : public content::RenderThreadObserver, 34 class ChromeRenderThreadObserver : public content::RenderThreadObserver,
34 public base::FieldTrialList::Observer, 35 public base::FieldTrialList::Observer,
36 public chrome::mojom::FieldTrialGroupSetter,
35 public chrome::mojom::RendererConfiguration { 37 public chrome::mojom::RendererConfiguration {
36 public: 38 public:
37 ChromeRenderThreadObserver(); 39 ChromeRenderThreadObserver();
38 ~ChromeRenderThreadObserver() override; 40 ~ChromeRenderThreadObserver() override;
39 41
40 static bool is_incognito_process() { return is_incognito_process_; } 42 static bool is_incognito_process() { return is_incognito_process_; }
41 43
42 // Returns a pointer to the content setting rules owned by 44 // Returns a pointer to the content setting rules owned by
43 // |ChromeRenderThreadObserver|. 45 // |ChromeRenderThreadObserver|.
44 const RendererContentSettingRules* content_setting_rules() const; 46 const RendererContentSettingRules* content_setting_rules() const;
45 47
46 visitedlink::VisitedLinkSlave* visited_link_slave() { 48 visitedlink::VisitedLinkSlave* visited_link_slave() {
47 return visited_link_slave_.get(); 49 return visited_link_slave_.get();
48 } 50 }
49 51
50 private: 52 private:
51 // content::RenderThreadObserver: 53 // content::RenderThreadObserver:
52 void RegisterMojoInterfaces( 54 void RegisterMojoInterfaces(
53 content::AssociatedInterfaceRegistry* associated_interfaces) override; 55 content::AssociatedInterfaceRegistry* associated_interfaces) override;
54 void UnregisterMojoInterfaces( 56 void UnregisterMojoInterfaces(
55 content::AssociatedInterfaceRegistry* associated_interfaces) override; 57 content::AssociatedInterfaceRegistry* associated_interfaces) override;
56 bool OnControlMessageReceived(const IPC::Message& message) override;
57 void OnRenderProcessShutdown() override; 58 void OnRenderProcessShutdown() override;
58 59
59 // base::FieldTrialList::Observer: 60 // base::FieldTrialList::Observer:
60 void OnFieldTrialGroupFinalized(const std::string& trial_name, 61 void OnFieldTrialGroupFinalized(const std::string& trial_name,
61 const std::string& group_name) override; 62 const std::string& group_name) override;
62 63
64 // chrome::mojom::FieldTrialGroupSetter:
65 void SetFieldTrialGroup(const std::string& trial_name,
66 const std::string& group_name) override;
67
63 // chrome::mojom::RendererConfiguration: 68 // chrome::mojom::RendererConfiguration:
64 void SetInitialConfiguration(bool is_incognito_process) override; 69 void SetInitialConfiguration(bool is_incognito_process) override;
65 void SetContentSettingRules( 70 void SetContentSettingRules(
66 const RendererContentSettingRules& rules) override; 71 const RendererContentSettingRules& rules) override;
67 72
73 void OnFieldTrialGroupSetterAssociatedRequest(
74 chrome::mojom::FieldTrialGroupSetterAssociatedRequest request);
68 void OnRendererConfigurationAssociatedRequest( 75 void OnRendererConfigurationAssociatedRequest(
69 chrome::mojom::RendererConfigurationAssociatedRequest request); 76 chrome::mojom::RendererConfigurationAssociatedRequest request);
70 77
71 void OnSetFieldTrialGroup(const std::string& trial_name,
72 const std::string& group_name);
73
74 static bool is_incognito_process_; 78 static bool is_incognito_process_;
75 std::unique_ptr<content::ResourceDispatcherDelegate> resource_delegate_; 79 std::unique_ptr<content::ResourceDispatcherDelegate> resource_delegate_;
76 RendererContentSettingRules content_setting_rules_; 80 RendererContentSettingRules content_setting_rules_;
77 variations::ChildProcessFieldTrialSyncer field_trial_syncer_; 81 variations::ChildProcessFieldTrialSyncer field_trial_syncer_;
78 82
79 std::unique_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_; 83 std::unique_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
80 84
85 mojo::AssociatedBindingSet<chrome::mojom::FieldTrialGroupSetter>
86 field_trial_group_setter_bindings_;
81 mojo::AssociatedBindingSet<chrome::mojom::RendererConfiguration> 87 mojo::AssociatedBindingSet<chrome::mojom::RendererConfiguration>
82 renderer_configuration_bindings_; 88 renderer_configuration_bindings_;
83 89
84 base::WeakPtrFactory<ChromeRenderThreadObserver> weak_factory_; 90 base::WeakPtrFactory<ChromeRenderThreadObserver> weak_factory_;
85 91
86 DISALLOW_COPY_AND_ASSIGN(ChromeRenderThreadObserver); 92 DISALLOW_COPY_AND_ASSIGN(ChromeRenderThreadObserver);
87 }; 93 };
88 94
89 #endif // CHROME_RENDERER_CHROME_RENDER_THREAD_OBSERVER_H_ 95 #endif // CHROME_RENDERER_CHROME_RENDER_THREAD_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698