Skip to content

Commit

Permalink
Add DataReductionProxy IPC to determine if the Data Reduction Proxy w…
Browse files Browse the repository at this point in the history
…as used.

The current mechanism is to create an instance of DataReductionProxyParams
inside of page_load_histogram, and to then check the proxy server inside of
DocumentState against DataReductionProxyParams. However, the plan is to make
the configuration dynamic, so we can no longer use DataReductionProxyParams.

BUG=452773

Review URL: https://codereview.chromium.org/966443002

Cr-Commit-Position: refs/heads/master@{#318917}
  • Loading branch information
jeremyim authored and Commit bot committed Mar 3, 2015
1 parent 0171e3c commit 364ac11
Show file tree
Hide file tree
Showing 24 changed files with 363 additions and 49 deletions.
2 changes: 1 addition & 1 deletion chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ static_library("browser") {
"//chrome/installer/util",
"//components/app_modal",
"//components/autofill/content/browser",
"//components/data_reduction_proxy/content/browser",
"//components/dom_distiller/content",
"//components/history/content/browser",
"//components/keyed_service/content",
Expand Down Expand Up @@ -594,7 +595,6 @@ static_library("browser") {
deps += [
":jni_headers",
"//components/cdm/browser",
"//components/data_reduction_proxy/content/browser",
"//components/enhanced_bookmarks",
"//components/resources:components_resources",
"//components/web_contents_delegate_android",
Expand Down
10 changes: 10 additions & 0 deletions chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#include "chrome/browser/metrics/rappor/sampling.h"
#include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_factory.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/notifications/desktop_notification_service_factory.h"
#include "chrome/browser/notifications/platform_notification_service_impl.h"
Expand Down Expand Up @@ -100,6 +102,7 @@
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/permission_request_id.h"
#include "components/data_reduction_proxy/content/browser/data_reduction_proxy_message_filter.h"
#include "components/dom_distiller/core/url_constants.h"
#include "components/google/core/browser/google_util.h"
#include "components/metrics/client_info.h"
Expand Down Expand Up @@ -944,6 +947,13 @@ void ChromeContentBrowserClient::RenderProcessWillLaunch(
if (switches::IsEnableAccountConsistency())
host->AddFilter(new PrincipalsMessageFilter(id));

DataReductionProxyChromeSettings* data_reduction_proxy_settings =
DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile);
if (data_reduction_proxy_settings) {
host->AddFilter(new data_reduction_proxy::DataReductionProxyMessageFilter(
data_reduction_proxy_settings));
}

host->Send(new ChromeViewMsg_SetIsIncognitoProcess(
profile->IsOffTheRecord()));

Expand Down
1 change: 1 addition & 0 deletions chrome/chrome_browser.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -3003,6 +3003,7 @@
'../third_party/re2/re2.gyp:re2',
'../cc/cc.gyp:cc',
'../components/components.gyp:autofill_content_browser',
'../components/components.gyp:data_reduction_proxy_content_browser',
'../components/components.gyp:dom_distiller_content',
'../components/components.gyp:history_content_browser',
'../components/components.gyp:keyed_service_content',
Expand Down
2 changes: 1 addition & 1 deletion chrome/chrome_renderer.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
'../third_party/re2/re2.gyp:re2',
'../components/components.gyp:autofill_content_renderer',
'../components/components.gyp:cdm_renderer',
'../components/components.gyp:data_reduction_proxy_core_common',
'../components/components.gyp:data_reduction_proxy_content_common',
'../components/components.gyp:network_hints_renderer',
'../components/components.gyp:error_page_renderer',
'../components/components.gyp:startup_metric_utils',
Expand Down
2 changes: 1 addition & 1 deletion chrome/renderer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static_library("renderer") {
"//chrome:strings",
"//components/autofill/content/renderer",
"//components/cdm/renderer",
"//components/data_reduction_proxy/core/common",
"//components/data_reduction_proxy/content/common",
"//components/network_hints/renderer",
"//components/error_page/renderer",
"//components/password_manager/content/renderer",
Expand Down
2 changes: 1 addition & 1 deletion chrome/renderer/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include_rules = [
"+components/cdm/renderer",
"+components/content_settings/core/common",
"+components/crx_file",
"+components/data_reduction_proxy/core/common",
"+components/data_reduction_proxy/content/common",
"+components/dom_distiller/core",
"+components/nacl/common",
"+components/nacl/renderer",
Expand Down
17 changes: 8 additions & 9 deletions chrome/renderer/page_load_histograms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "base/time/time.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/renderer/chrome_content_renderer_client.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h"
#include "components/data_reduction_proxy/content/common/data_reduction_proxy_messages.h"
#include "content/public/common/content_constants.h"
#include "content/public/renderer/document_state.h"
#include "content/public/renderer/render_thread.h"
Expand Down Expand Up @@ -724,11 +724,7 @@ void DumpDeprecatedHistograms(const WebPerformance& performance,
} // namespace

PageLoadHistograms::PageLoadHistograms(content::RenderView* render_view)
: content::RenderViewObserver(render_view),
data_reduction_proxy_params_(
data_reduction_proxy::DataReductionProxyParams::kAllowed |
data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed |
data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed) {
: content::RenderViewObserver(render_view) {
}

void PageLoadHistograms::Dump(WebFrame* frame) {
Expand All @@ -750,9 +746,12 @@ void PageLoadHistograms::Dump(WebFrame* frame) {
DocumentState* document_state =
DocumentState::FromDataSource(frame->dataSource());

bool data_reduction_proxy_was_used =
data_reduction_proxy_params_.IsDataReductionProxy(
document_state->proxy_server(), NULL);
bool data_reduction_proxy_was_used = false;
if (!document_state->proxy_server().IsEmpty()) {
Send(new DataReductionProxyViewHostMsg_IsDataReductionProxy(
document_state->proxy_server(), &data_reduction_proxy_was_used));
}

bool came_from_websearch =
IsFromGoogleSearchResult(frame->document().url(),
GURL(frame->document().referrer()));
Expand Down
3 changes: 0 additions & 3 deletions chrome/renderer/page_load_histograms.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#define CHROME_RENDERER_PAGE_LOAD_HISTOGRAMS_H_

#include "base/basictypes.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
#include "content/public/renderer/render_view_observer.h"

namespace content {
Expand Down Expand Up @@ -46,8 +45,6 @@ class PageLoadHistograms : public content::RenderViewObserver {
void LogPageLoadTime(const content::DocumentState* load_times,
const blink::WebDataSource* ds) const;

data_reduction_proxy::DataReductionProxyParams data_reduction_proxy_params_;

DISALLOW_COPY_AND_ASSIGN(PageLoadHistograms);
};

Expand Down
5 changes: 1 addition & 4 deletions components/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ test("components_unittests") {
"//components/content_settings/core/browser:unit_tests",
"//components/content_settings/core/common:unit_tests",
"//components/crx_file:unit_tests",
"//components/data_reduction_proxy/content/browser:unit_tests",
"//components/data_reduction_proxy/core/browser:unit_tests",
"//components/data_reduction_proxy/core/common:unit_tests",
"//components/device_event_log:unit_tests",
Expand Down Expand Up @@ -269,10 +270,6 @@ test("components_unittests") {
]
data_deps = [ ":components_tests_pak" ]

if (is_android) {
deps += [ "//components/data_reduction_proxy/content/browser:unit_tests" ]
}

# TODO(GYP) need this target.
#'breakpad/app/crash_keys_win_unittest.cc',

Expand Down
2 changes: 2 additions & 0 deletions components/components_tests.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@
['OS != "ios"', {
'sources': [
'autofill/content/renderer/renderer_save_password_progress_logger_unittest.cc',
'data_reduction_proxy/content/browser/data_reduction_proxy_message_filter_unittest.cc',
'dom_distiller/content/dom_distiller_viewer_source_unittest.cc',
'dom_distiller/content/web_contents_main_frame_observer_unittest.cc',
'error_page/renderer/net_error_helper_core_unittest.cc',
Expand All @@ -505,6 +506,7 @@
'components.gyp:autofill_content_browser',
'components.gyp:autofill_content_renderer',
'components.gyp:autofill_content_test_support',
'components.gyp:data_reduction_proxy_content_browser',
'components.gyp:dom_distiller_content',
'components.gyp:error_page_renderer',
'components.gyp:history_content_browser',
Expand Down
34 changes: 33 additions & 1 deletion components/data_reduction_proxy.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,39 @@
'data_reduction_proxy/content/browser/data_reduction_proxy_debug_ui_manager.h',
],
},
{
# GN version: //components/data_reduction_proxy/content/common
'target_name': 'data_reduction_proxy_content_common',
'type': 'static_library',
'dependencies': [
'../content/content.gyp:content_common',
'../ipc/ipc.gyp:ipc',
],
'include_dirs': [
'..',
],
'sources': [
'data_reduction_proxy/content/common/data_reduction_proxy_messages.cc',
'data_reduction_proxy/content/common/data_reduction_proxy_messages.h',
],
},
{
# GN version: //components/data_reduction_proxy/content/browser
'target_name': 'data_reduction_proxy_content_browser',
'type': 'static_library',
'dependencies': [
'../content/content.gyp:content_common',
'../ipc/ipc.gyp:ipc',
'data_reduction_proxy_content_common',
],
'include_dirs': [
'..',
],
'sources': [
'data_reduction_proxy/content/browser/data_reduction_proxy_message_filter.cc',
'data_reduction_proxy/content/browser/data_reduction_proxy_message_filter.h',
],
},
{
# GN version: //components/data_reduction_proxy/core/browser
'target_name': 'data_reduction_proxy_core_browser',
Expand Down Expand Up @@ -181,6 +214,5 @@
},
],
},

],
}
14 changes: 14 additions & 0 deletions components/data_reduction_proxy/OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,17 @@ bengr@chromium.org
bolian@chromium.org
marq@chromium.org
sclittle@chromium.org

# Changes to IPC messages require a security review to avoid introducing
# new sandbox escapes.
per-file *_messages.*=set noparent
per-file *_messages.*=dcheng@chromium.org
per-file *_messages.*=inferno@chromium.org
per-file *_messages.*=jln@chromium.org
per-file *_messages.*=jschuh@chromium.org
per-file *_messages.*=kenrb@chromium.org
per-file *_messages.*=mkwst@chromium.org
per-file *_messages.*=nasko@chromium.org
per-file *_messages.*=palmer@chromium.org
per-file *_messages.*=tsepez@chromium.org
per-file *_messages.*=wfh@chromium.org
64 changes: 44 additions & 20 deletions components/data_reduction_proxy/content/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,64 @@

static_library("browser") {
sources = [
"content_data_reduction_proxy_debug_ui_service.cc",
"content_data_reduction_proxy_debug_ui_service.h",
"data_reduction_proxy_debug_blocking_page.cc",
"data_reduction_proxy_debug_blocking_page.h",
"data_reduction_proxy_debug_resource_throttle.cc",
"data_reduction_proxy_debug_resource_throttle.h",
"data_reduction_proxy_debug_ui_manager.cc",
"data_reduction_proxy_debug_ui_manager.h",
"data_reduction_proxy_message_filter.cc",
"data_reduction_proxy_message_filter.h",
]

deps = [
"//base",
"//components/resources",
"//components/strings",
"//components/data_reduction_proxy/content/common",
"//content/public/browser",
"//skia",
"//ui/base",
"//ipc",
"//net",
]

if (is_android) {
sources += [
"content_data_reduction_proxy_debug_ui_service.cc",
"content_data_reduction_proxy_debug_ui_service.h",
"data_reduction_proxy_debug_blocking_page.cc",
"data_reduction_proxy_debug_blocking_page.h",
"data_reduction_proxy_debug_resource_throttle.cc",
"data_reduction_proxy_debug_resource_throttle.h",
"data_reduction_proxy_debug_ui_manager.cc",
"data_reduction_proxy_debug_ui_manager.h",
]

deps += [
"//components/resources",
"//components/strings",
"//skia",
"//ui/base",
]
}
}

if (is_android) {
source_set("unit_tests") {
testonly = true
sources = [
source_set("unit_tests") {
testonly = true
sources = [
"data_reduction_proxy_message_filter_unittest.cc",
]

deps = [
":browser",
"//base",
"//components/data_reduction_proxy/core/browser:test_support",
"//components/data_reduction_proxy/core/common:test_support",
"//net",
"//testing/gtest",
"//testing/gmock",
]

if (is_android) {
sources += [
"data_reduction_proxy_debug_blocking_page_unittest.cc",
"data_reduction_proxy_debug_resource_throttle_unittest.cc",
"data_reduction_proxy_debug_ui_manager_unittest.cc",
]

deps = [
":browser",
deps += [
"//skia",
"//testing/gtest",
"//testing/gmock",
"//third_party/mojo/src/mojo/public/cpp/bindings",
]
}
Expand Down
4 changes: 4 additions & 0 deletions components/data_reduction_proxy/content/browser/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include_rules = [
"+ipc",
"+net",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/data_reduction_proxy/content/browser/data_reduction_proxy_message_filter.h"

#include "components/data_reduction_proxy/content/common/data_reduction_proxy_messages.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
#include "content/public/browser/browser_thread.h"
#include "ipc/ipc_message_macros.h"
#include "net/base/host_port_pair.h"

namespace data_reduction_proxy {

DataReductionProxyMessageFilter::DataReductionProxyMessageFilter(
DataReductionProxySettings* settings)
: BrowserMessageFilter(DataReductionProxyStart),
config_(nullptr) {
DCHECK(settings);
config_ = settings->Config();
}

DataReductionProxyMessageFilter::~DataReductionProxyMessageFilter() {
}

bool DataReductionProxyMessageFilter::OnMessageReceived(
const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(DataReductionProxyMessageFilter, message)
IPC_MESSAGE_HANDLER(DataReductionProxyViewHostMsg_IsDataReductionProxy,
OnIsDataReductionProxy)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}

void DataReductionProxyMessageFilter::OverrideThreadForMessage(
const IPC::Message& message, content::BrowserThread::ID* thread) {
if (message.type() ==
DataReductionProxyViewHostMsg_IsDataReductionProxy::ID) {
*thread = content::BrowserThread::IO;
}
}

void DataReductionProxyMessageFilter::OnIsDataReductionProxy(
const net::HostPortPair& proxy_server, bool* response) {
if (config_)
*response = config_->IsDataReductionProxy(proxy_server, nullptr);
else
*response = false;
}

} // namespace data_reduction_proxy
Loading

0 comments on commit 364ac11

Please sign in to comment.