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_BROWSER_RENDERER_HOST_CHROME_RENDER_MESSAGE_FILTER_H_
6 #define CHROME_BROWSER_RENDERER_HOST_CHROME_RENDER_MESSAGE_FILTER_H_
11 #include "base/callback.h"
12 #include "base/sequenced_task_runner_helpers.h"
13 #include "content/public/browser/browser_message_filter.h"
14 #include "third_party/WebKit/public/web/WebCache.h"
20 namespace chrome_browser_net {
24 namespace extensions {
28 // This class filters out incoming Chrome-specific IPC messages for the renderer
29 // process on the IPC thread.
30 class ChromeRenderMessageFilter : public content::BrowserMessageFilter {
32 ChromeRenderMessageFilter(int render_process_id, Profile* profile);
34 class V8HeapStatsDetails {
36 V8HeapStatsDetails(size_t v8_memory_allocated,
37 size_t v8_memory_used)
38 : v8_memory_allocated_(v8_memory_allocated),
39 v8_memory_used_(v8_memory_used) {}
40 size_t v8_memory_allocated() const { return v8_memory_allocated_; }
41 size_t v8_memory_used() const { return v8_memory_used_; }
43 size_t v8_memory_allocated_;
44 size_t v8_memory_used_;
47 // content::BrowserMessageFilter methods:
48 bool OnMessageReceived(const IPC::Message& message) override;
49 void OverrideThreadForMessage(const IPC::Message& message,
50 content::BrowserThread::ID* thread) override;
53 friend class content::BrowserThread;
54 friend class base::DeleteHelper<ChromeRenderMessageFilter>;
56 ~ChromeRenderMessageFilter() override;
58 void OnDnsPrefetch(const std::vector<std::string>& hostnames);
59 void OnPreconnect(const GURL& url);
60 void OnResourceTypeStats(const blink::WebCache::ResourceTypeStats& stats);
61 void OnUpdatedCacheStats(const blink::WebCache::UsageStats& stats);
62 void OnV8HeapStats(int v8_memory_allocated, int v8_memory_used);
64 void OnAllowDatabase(int render_frame_id,
65 const GURL& origin_url,
66 const GURL& top_origin_url,
67 const base::string16& name,
68 const base::string16& display_name,
70 void OnAllowDOMStorage(int render_frame_id,
71 const GURL& origin_url,
72 const GURL& top_origin_url,
75 void OnRequestFileSystemAccessSync(int render_frame_id,
76 const GURL& origin_url,
77 const GURL& top_origin_url,
78 IPC::Message* message);
79 #if defined(ENABLE_EXTENSIONS)
80 static void FileSystemAccessedSyncOnUIThread(
81 int render_process_id,
84 bool blocked_by_policy,
85 IPC::Message* reply_msg);
87 void OnRequestFileSystemAccessAsync(int render_frame_id,
89 const GURL& origin_url,
90 const GURL& top_origin_url);
91 void OnRequestFileSystemAccessSyncResponse(IPC::Message* reply_msg,
93 void OnRequestFileSystemAccessAsyncResponse(int render_frame_id,
96 void OnRequestFileSystemAccess(int render_frame_id,
97 const GURL& origin_url,
98 const GURL& top_origin_url,
99 base::Callback<void(bool)> callback);
100 #if defined(ENABLE_EXTENSIONS)
101 static void FileSystemAccessedOnUIThread(int render_process_id,
105 base::Callback<void(bool)> callback);
106 static void FileSystemAccessedResponse(int render_process_id,
109 base::Callback<void(bool)> callback,
112 void OnAllowIndexedDB(int render_frame_id,
113 const GURL& origin_url,
114 const GURL& top_origin_url,
115 const base::string16& name,
117 #if defined(ENABLE_PLUGINS)
118 void OnIsCrashReportingEnabled(bool* enabled);
121 const int render_process_id_;
123 // The Profile associated with our renderer process. This should only be
124 // accessed on the UI thread!
126 // The Predictor for the associated Profile. It is stored so that it can be
127 // used on the IO thread.
128 chrome_browser_net::Predictor* predictor_;
130 // Used to look up permissions at database creation time.
131 scoped_refptr<CookieSettings> cookie_settings_;
133 DISALLOW_COPY_AND_ASSIGN(ChromeRenderMessageFilter);
136 #endif // CHROME_BROWSER_RENDERER_HOST_CHROME_RENDER_MESSAGE_FILTER_H_