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
3 // found in the LICENSE file.
5 #ifndef CHROME_RENDERER_CHROME_RENDER_PROCESS_OBSERVER_H_
6 #define CHROME_RENDERER_CHROME_RENDER_PROCESS_OBSERVER_H_
11 #include "base/compiler_specific.h"
12 #include "base/file_path.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/common/content_settings.h"
15 #include "content/public/renderer/render_process_observer.h"
18 struct ContentSettings
;
21 class ChromeContentRendererClient
;
25 class ResourceDispatcherDelegate
;
28 // This class filters the incoming control messages (i.e. ones not destined for
29 // a RenderView) for Chrome specific messages that the content layer doesn't
30 // happen. If a few messages are related, they should probably have their own
32 class ChromeRenderProcessObserver
: public content::RenderProcessObserver
{
34 explicit ChromeRenderProcessObserver(
35 chrome::ChromeContentRendererClient
* client
);
36 virtual ~ChromeRenderProcessObserver();
38 static bool is_incognito_process() { return is_incognito_process_
; }
40 // Needs to be called by RenderViews in case of navigations to execute
41 // any 'clear cache' commands that were delayed until the next navigation.
42 void ExecutePendingClearCache();
44 // Returns a pointer to the content setting rules owned by
45 // |ChromeRenderProcessObserver|.
46 const RendererContentSettingRules
* content_setting_rules() const;
49 // RenderProcessObserver implementation.
50 virtual bool OnControlMessageReceived(const IPC::Message
& message
) OVERRIDE
;
52 void OnSetIsIncognitoProcess(bool is_incognito_process
);
53 void OnSetContentSettingsForCurrentURL(
54 const GURL
& url
, const ContentSettings
& content_settings
);
55 void OnSetContentSettingRules(const RendererContentSettingRules
& rules
);
56 void OnSetCacheCapacities(size_t min_dead_capacity
,
57 size_t max_dead_capacity
,
59 // If |on_navigation| is true, the clearing is delayed until the next
61 void OnClearCache(bool on_navigation
);
62 void OnGetCacheResourceStats();
63 void OnSetFieldTrialGroup(const std::string
& fiel_trial_name
,
64 const std::string
& group_name
);
65 void OnSetTcmallocHeapProfiling(bool profiling
, const std::string
& prefix
);
66 void OnWriteTcmallocHeapProfile(const FilePath::StringType
& filename
);
67 void OnGetV8HeapStats();
70 static bool is_incognito_process_
;
71 scoped_ptr
<content::ResourceDispatcherDelegate
> resource_delegate_
;
72 chrome::ChromeContentRendererClient
* client_
;
73 // If true, the web cache shall be cleared before the next navigation event.
74 bool clear_cache_pending_
;
75 RendererContentSettingRules content_setting_rules_
;
77 DISALLOW_COPY_AND_ASSIGN(ChromeRenderProcessObserver
);
80 #endif // CHROME_RENDERER_CHROME_RENDER_PROCESS_OBSERVER_H_