OLD | NEW |
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/variations/child_process_field_trial_syncer.h" | 15 #include "chrome/common/variations/child_process_field_trial_syncer.h" |
16 #include "components/content_settings/core/common/content_settings.h" | 16 #include "components/content_settings/core/common/content_settings.h" |
17 #include "content/public/renderer/render_thread_observer.h" | 17 #include "content/public/renderer/render_thread_observer.h" |
18 | 18 |
19 class GURL; | 19 class GURL; |
20 struct ContentSettings; | 20 struct ContentSettings; |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class CommandLine; | 23 class CommandLine; |
24 } | 24 } |
25 | 25 |
26 namespace content { | 26 namespace content { |
27 class ResourceDispatcherDelegate; | 27 class ResourceDispatcherDelegate; |
28 } | 28 } |
29 | 29 |
30 namespace network_hints { | |
31 class PrescientNetworkingDispatcher; | |
32 } | |
33 | |
34 // 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 |
35 // 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 |
36 // 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 |
37 // observer. | 33 // observer. |
38 class ChromeRenderThreadObserver : public content::RenderThreadObserver, | 34 class ChromeRenderThreadObserver : public content::RenderThreadObserver, |
39 public base::FieldTrialList::Observer { | 35 public base::FieldTrialList::Observer { |
40 public: | 36 public: |
41 ChromeRenderThreadObserver(); | 37 ChromeRenderThreadObserver(); |
42 ~ChromeRenderThreadObserver() override; | 38 ~ChromeRenderThreadObserver() override; |
43 | 39 |
44 static bool is_incognito_process() { return is_incognito_process_; } | 40 static bool is_incognito_process() { return is_incognito_process_; } |
45 | 41 |
46 // Returns a pointer to the content setting rules owned by | 42 // Returns a pointer to the content setting rules owned by |
47 // |ChromeRenderThreadObserver|. | 43 // |ChromeRenderThreadObserver|. |
48 const RendererContentSettingRules* content_setting_rules() const; | 44 const RendererContentSettingRules* content_setting_rules() const; |
49 | 45 |
50 network_hints::PrescientNetworkingDispatcher* | |
51 prescient_networking_dispatcher() { | |
52 return prescient_networking_dispatcher_.get(); | |
53 } | |
54 | |
55 private: | 46 private: |
56 // Initializes field trial state change observation and notifies the browser | 47 // Initializes field trial state change observation and notifies the browser |
57 // of any field trials that might have already been activated. | 48 // of any field trials that might have already been activated. |
58 void InitFieldTrialObserving(const base::CommandLine& command_line); | 49 void InitFieldTrialObserving(const base::CommandLine& command_line); |
59 | 50 |
60 // content::RenderThreadObserver: | 51 // content::RenderThreadObserver: |
61 bool OnControlMessageReceived(const IPC::Message& message) override; | 52 bool OnControlMessageReceived(const IPC::Message& message) override; |
62 void OnRenderProcessShutdown() override; | |
63 | 53 |
64 // base::FieldTrialList::Observer: | 54 // base::FieldTrialList::Observer: |
65 void OnFieldTrialGroupFinalized(const std::string& trial_name, | 55 void OnFieldTrialGroupFinalized(const std::string& trial_name, |
66 const std::string& group_name) override; | 56 const std::string& group_name) override; |
67 | 57 |
68 void OnSetIsIncognitoProcess(bool is_incognito_process); | 58 void OnSetIsIncognitoProcess(bool is_incognito_process); |
69 void OnSetContentSettingsForCurrentURL( | 59 void OnSetContentSettingsForCurrentURL( |
70 const GURL& url, const ContentSettings& content_settings); | 60 const GURL& url, const ContentSettings& content_settings); |
71 void OnSetContentSettingRules(const RendererContentSettingRules& rules); | 61 void OnSetContentSettingRules(const RendererContentSettingRules& rules); |
72 void OnGetCacheResourceStats(); | 62 void OnGetCacheResourceStats(); |
73 void OnSetFieldTrialGroup(const std::string& trial_name, | 63 void OnSetFieldTrialGroup(const std::string& trial_name, |
74 const std::string& group_name); | 64 const std::string& group_name); |
75 | 65 |
76 static bool is_incognito_process_; | 66 static bool is_incognito_process_; |
77 std::unique_ptr<content::ResourceDispatcherDelegate> resource_delegate_; | 67 std::unique_ptr<content::ResourceDispatcherDelegate> resource_delegate_; |
78 RendererContentSettingRules content_setting_rules_; | 68 RendererContentSettingRules content_setting_rules_; |
79 chrome_variations::ChildProcessFieldTrialSyncer field_trial_syncer_; | 69 chrome_variations::ChildProcessFieldTrialSyncer field_trial_syncer_; |
80 | 70 |
81 std::unique_ptr<network_hints::PrescientNetworkingDispatcher> | |
82 prescient_networking_dispatcher_; | |
83 | |
84 base::WeakPtrFactory<ChromeRenderThreadObserver> weak_factory_; | 71 base::WeakPtrFactory<ChromeRenderThreadObserver> weak_factory_; |
85 | 72 |
86 DISALLOW_COPY_AND_ASSIGN(ChromeRenderThreadObserver); | 73 DISALLOW_COPY_AND_ASSIGN(ChromeRenderThreadObserver); |
87 }; | 74 }; |
88 | 75 |
89 #endif // CHROME_RENDERER_CHROME_RENDER_THREAD_OBSERVER_H_ | 76 #endif // CHROME_RENDERER_CHROME_RENDER_THREAD_OBSERVER_H_ |
OLD | NEW |