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

Side by Side Diff: chrome/browser/renderer_host/chrome_render_message_filter.cc

Issue 2144533002: Convert network hints to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change ownership of PrescientNetworkingDispatcher for proper shutdown Created 4 years, 5 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 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" 5 #include "chrome/browser/renderer_host/chrome_render_message_filter.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/metrics/field_trial.h" 15 #include "base/metrics/field_trial.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/chrome_notification_types.h" 17 #include "chrome/browser/chrome_notification_types.h"
18 #include "chrome/browser/content_settings/cookie_settings_factory.h" 18 #include "chrome/browser/content_settings/cookie_settings_factory.h"
19 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 19 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
20 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" 20 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
21 #include "chrome/browser/net/predictor.h" 21 #include "chrome/browser/net/predictor.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/profiles/profile_manager.h" 23 #include "chrome/browser/profiles/profile_manager.h"
24 #include "chrome/common/render_messages.h" 24 #include "chrome/common/render_messages.h"
25 #include "components/content_settings/content/common/content_settings_messages.h " 25 #include "components/content_settings/content/common/content_settings_messages.h "
26 #include "components/content_settings/core/browser/cookie_settings.h" 26 #include "components/content_settings/core/browser/cookie_settings.h"
27 #include "components/network_hints/common/network_hints_common.h" 27 #include "components/network_hints/common/network_hints_common.h"
28 #include "components/network_hints/common/network_hints_messages.h" 28 #include "components/network_hints/common/network_hints_param_traits.h"
Sam McNally 2016/07/20 00:03:01 Remove.
tibell 2016/07/20 00:29:34 Done.
29 #include "components/rappor/rappor_service.h" 29 #include "components/rappor/rappor_service.h"
30 #include "components/rappor/rappor_utils.h" 30 #include "components/rappor/rappor_utils.h"
31 #include "components/web_cache/browser/web_cache_manager.h" 31 #include "components/web_cache/browser/web_cache_manager.h"
32 #include "content/public/browser/notification_service.h" 32 #include "content/public/browser/notification_service.h"
33 #include "content/public/browser/render_process_host.h" 33 #include "content/public/browser/render_process_host.h"
34 34
35 #if defined(ENABLE_EXTENSIONS) 35 #if defined(ENABLE_EXTENSIONS)
36 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" 36 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h"
37 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" 37 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
38 #include "extensions/common/manifest_handlers/default_locale_handler.h" 38 #include "extensions/common/manifest_handlers/default_locale_handler.h"
39 #endif 39 #endif
40 40
41 using content::BrowserThread; 41 using content::BrowserThread;
42 42
43 namespace { 43 namespace {
44 44
45 const uint32_t kFilteredMessageClasses[] = { 45 const uint32_t kFilteredMessageClasses[] = {ChromeMsgStart,
46 ChromeMsgStart, ContentSettingsMsgStart, NetworkHintsMsgStart, 46 ContentSettingsMsgStart};
47 };
48 47
49 } // namespace 48 } // namespace
50 49
51 ChromeRenderMessageFilter::ChromeRenderMessageFilter(int render_process_id, 50 ChromeRenderMessageFilter::ChromeRenderMessageFilter(int render_process_id,
52 Profile* profile) 51 Profile* profile)
53 : BrowserMessageFilter(kFilteredMessageClasses, 52 : BrowserMessageFilter(kFilteredMessageClasses,
54 arraysize(kFilteredMessageClasses)), 53 arraysize(kFilteredMessageClasses)),
55 render_process_id_(render_process_id), 54 render_process_id_(render_process_id),
56 profile_(profile), 55 profile_(profile),
57 predictor_(profile_->GetNetworkPredictor()), 56 predictor_(profile_->GetNetworkPredictor()),
58 cookie_settings_(CookieSettingsFactory::GetForProfile(profile)) { 57 cookie_settings_(CookieSettingsFactory::GetForProfile(profile)) {
59 } 58 }
60 59
61 ChromeRenderMessageFilter::~ChromeRenderMessageFilter() { 60 ChromeRenderMessageFilter::~ChromeRenderMessageFilter() {
62 } 61 }
63 62
64 bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message) { 63 bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message) {
65 bool handled = true; 64 bool handled = true;
66 IPC_BEGIN_MESSAGE_MAP(ChromeRenderMessageFilter, message) 65 IPC_BEGIN_MESSAGE_MAP(ChromeRenderMessageFilter, message)
67 IPC_MESSAGE_HANDLER(NetworkHintsMsg_DNSPrefetch, OnDnsPrefetch)
68 IPC_MESSAGE_HANDLER(NetworkHintsMsg_Preconnect, OnPreconnect)
69 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_UpdatedCacheStats, 66 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_UpdatedCacheStats,
70 OnUpdatedCacheStats) 67 OnUpdatedCacheStats)
71 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDatabase, OnAllowDatabase) 68 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDatabase, OnAllowDatabase)
72 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDOMStorage, OnAllowDOMStorage) 69 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDOMStorage, OnAllowDOMStorage)
73 IPC_MESSAGE_HANDLER_DELAY_REPLY( 70 IPC_MESSAGE_HANDLER_DELAY_REPLY(
74 ChromeViewHostMsg_RequestFileSystemAccessSync, 71 ChromeViewHostMsg_RequestFileSystemAccessSync,
75 OnRequestFileSystemAccessSync) 72 OnRequestFileSystemAccessSync)
76 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RequestFileSystemAccessAsync, 73 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RequestFileSystemAccessAsync,
77 OnRequestFileSystemAccessAsync) 74 OnRequestFileSystemAccessAsync)
78 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowIndexedDB, OnAllowIndexedDB) 75 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowIndexedDB, OnAllowIndexedDB)
(...skipping 20 matching lines...) Expand all
99 case ChromeViewHostMsg_UpdatedCacheStats::ID: 96 case ChromeViewHostMsg_UpdatedCacheStats::ID:
100 case ChromeViewHostMsg_RecordRappor::ID: 97 case ChromeViewHostMsg_RecordRappor::ID:
101 case ChromeViewHostMsg_RecordRapporURL::ID: 98 case ChromeViewHostMsg_RecordRapporURL::ID:
102 *thread = BrowserThread::UI; 99 *thread = BrowserThread::UI;
103 break; 100 break;
104 default: 101 default:
105 break; 102 break;
106 } 103 }
107 } 104 }
108 105
109 void ChromeRenderMessageFilter::OnDnsPrefetch( 106 void ChromeRenderMessageFilter::DNSPrefetch(
110 const network_hints::LookupRequest& request) { 107 const network_hints::LookupRequest& request) {
111 if (predictor_) 108 if (predictor_)
112 predictor_->DnsPrefetchList(request.hostname_list); 109 predictor_->DnsPrefetchList(request.hostname_list);
113 } 110 }
114 111
115 void ChromeRenderMessageFilter::OnPreconnect(const GURL& url, 112 void ChromeRenderMessageFilter::Preconnect(const GURL& url,
116 bool allow_credentials, 113 bool allow_credentials,
117 int count) { 114 int count) {
118 if (count < 1) { 115 if (count < 1) {
119 LOG(WARNING) << "NetworkHintsMsg_Preconnect IPC with invalid count: " 116 LOG(WARNING) << "NetworkHints::Preconnect IPC with invalid count: "
120 << count; 117 << count;
121 return; 118 return;
122 } 119 }
123 if (predictor_ && url.is_valid() && url.has_host() && url.has_scheme() && 120 if (predictor_ && url.is_valid() && url.has_host() && url.has_scheme() &&
124 url.SchemeIsHTTPOrHTTPS()) { 121 url.SchemeIsHTTPOrHTTPS()) {
125 predictor_->PreconnectUrl(url, GURL(), 122 predictor_->PreconnectUrl(url, GURL(),
126 chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, 123 chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED,
127 allow_credentials, count); 124 allow_credentials, count);
128 } 125 }
129 } 126 }
130 127
128 void ChromeRenderMessageFilter::BindNetworkHints(
129 network_hints::mojom::NetworkHintsRequest request) {
130 bindings_.AddBinding(this, std::move(request));
131 }
132
131 void ChromeRenderMessageFilter::OnUpdatedCacheStats( 133 void ChromeRenderMessageFilter::OnUpdatedCacheStats(
132 uint64_t min_dead_capacity, 134 uint64_t min_dead_capacity,
133 uint64_t max_dead_capacity, 135 uint64_t max_dead_capacity,
134 uint64_t capacity, 136 uint64_t capacity,
135 uint64_t live_size, 137 uint64_t live_size,
136 uint64_t dead_size) { 138 uint64_t dead_size) {
137 web_cache::WebCacheManager::GetInstance()->ObserveStats( 139 web_cache::WebCacheManager::GetInstance()->ObserveStats(
138 render_process_id_, min_dead_capacity, max_dead_capacity, capacity, 140 render_process_id_, min_dead_capacity, max_dead_capacity, capacity,
139 live_size, dead_size); 141 live_size, dead_size);
140 } 142 }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 rappor::SampleString(g_browser_process->rappor_service(), metric, 353 rappor::SampleString(g_browser_process->rappor_service(), metric,
352 rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, sample); 354 rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, sample);
353 } 355 }
354 356
355 void ChromeRenderMessageFilter::OnRecordRapporURL(const std::string& metric, 357 void ChromeRenderMessageFilter::OnRecordRapporURL(const std::string& metric,
356 const GURL& sample) { 358 const GURL& sample) {
357 DCHECK_CURRENTLY_ON(BrowserThread::UI); 359 DCHECK_CURRENTLY_ON(BrowserThread::UI);
358 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), 360 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(),
359 metric, sample); 361 metric, sample);
360 } 362 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698