| Index: chrome/browser/chrome_net_benchmarking_message_filter.cc
|
| diff --git a/chrome/browser/chrome_net_benchmarking_message_filter.cc b/chrome/browser/chrome_net_benchmarking_message_filter.cc
|
| deleted file mode 100644
|
| index ef57cf85d7d71cfc8166bd924077254023f6f51a..0000000000000000000000000000000000000000
|
| --- a/chrome/browser/chrome_net_benchmarking_message_filter.cc
|
| +++ /dev/null
|
| @@ -1,159 +0,0 @@
|
| -// Copyright (c) 2012 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 "chrome/browser/chrome_net_benchmarking_message_filter.h"
|
| -
|
| -#include <memory>
|
| -
|
| -#include "base/bind.h"
|
| -#include "base/bind_helpers.h"
|
| -#include "base/command_line.h"
|
| -#include "base/macros.h"
|
| -#include "chrome/browser/net/predictor.h"
|
| -#include "chrome/browser/profiles/profile.h"
|
| -#include "chrome/common/benchmarking_messages.h"
|
| -#include "chrome/common/chrome_switches.h"
|
| -#include "net/base/net_errors.h"
|
| -#include "net/disk_cache/disk_cache.h"
|
| -#include "net/dns/host_cache.h"
|
| -#include "net/dns/host_resolver.h"
|
| -#include "net/http/http_cache.h"
|
| -#include "net/url_request/url_request_context.h"
|
| -#include "net/url_request/url_request_context_getter.h"
|
| -
|
| -namespace {
|
| -
|
| -void ClearCacheCallback(ChromeNetBenchmarkingMessageFilter* filter,
|
| - IPC::Message* reply_msg,
|
| - int result) {
|
| - ChromeViewHostMsg_ClearCache::WriteReplyParams(reply_msg, result);
|
| - filter->Send(reply_msg);
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| -ChromeNetBenchmarkingMessageFilter::ChromeNetBenchmarkingMessageFilter(
|
| - Profile* profile,
|
| - net::URLRequestContextGetter* request_context)
|
| - : BrowserMessageFilter(ChromeBenchmarkingMsgStart),
|
| - profile_(profile),
|
| - request_context_(request_context) {
|
| -}
|
| -
|
| -ChromeNetBenchmarkingMessageFilter::~ChromeNetBenchmarkingMessageFilter() {
|
| -}
|
| -
|
| -bool ChromeNetBenchmarkingMessageFilter::OnMessageReceived(
|
| - const IPC::Message& message) {
|
| - bool handled = true;
|
| - IPC_BEGIN_MESSAGE_MAP(ChromeNetBenchmarkingMessageFilter, message)
|
| - IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CloseCurrentConnections,
|
| - OnCloseCurrentConnections)
|
| - IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_ClearCache, OnClearCache)
|
| - IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ClearHostResolverCache,
|
| - OnClearHostResolverCache)
|
| - IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ClearPredictorCache,
|
| - OnClearPredictorCache)
|
| - IPC_MESSAGE_UNHANDLED(handled = false)
|
| - IPC_END_MESSAGE_MAP()
|
| - return handled;
|
| -}
|
| -
|
| -void ChromeNetBenchmarkingMessageFilter::OverrideThreadForMessage(
|
| - const IPC::Message& message,
|
| - content::BrowserThread::ID* thread) {
|
| - if (message.type() == ChromeViewHostMsg_ClearPredictorCache::ID)
|
| - *thread = content::BrowserThread::UI;
|
| -}
|
| -
|
| -void ChromeNetBenchmarkingMessageFilter::OnClearCache(IPC::Message* reply_msg) {
|
| - // This function is disabled unless the user has enabled
|
| - // benchmarking extensions.
|
| - if (!CheckBenchmarkingEnabled()) {
|
| - NOTREACHED() << "Received unexpected benchmarking IPC";
|
| - return;
|
| - }
|
| - int rv = -1;
|
| -
|
| - disk_cache::Backend* backend = request_context_->GetURLRequestContext()->
|
| - http_transaction_factory()->GetCache()->GetCurrentBackend();
|
| - if (backend) {
|
| - net::CompletionCallback callback =
|
| - base::Bind(&ClearCacheCallback, base::RetainedRef(this), reply_msg);
|
| - rv = backend->DoomAllEntries(callback);
|
| - if (rv == net::ERR_IO_PENDING) {
|
| - // The callback will send the reply.
|
| - return;
|
| - }
|
| - }
|
| - ChromeViewHostMsg_ClearCache::WriteReplyParams(reply_msg, rv);
|
| - Send(reply_msg);
|
| -}
|
| -
|
| -void ChromeNetBenchmarkingMessageFilter::OnClearHostResolverCache() {
|
| - // This function is disabled unless the user has enabled
|
| - // benchmarking extensions.
|
| - if (!CheckBenchmarkingEnabled()) {
|
| - NOTREACHED() << "Received unexpected benchmarking IPC";
|
| - return;
|
| - }
|
| - net::HostCache* cache =
|
| - request_context_->GetURLRequestContext()->host_resolver()->GetHostCache();
|
| - if (cache) {
|
| - cache->clear();
|
| - }
|
| -}
|
| -
|
| -void ChromeNetBenchmarkingMessageFilter::OnCloseCurrentConnections() {
|
| - // This function is disabled unless the user has enabled
|
| - // benchmarking extensions.
|
| - if (!CheckBenchmarkingEnabled()) {
|
| - NOTREACHED() << "Received unexpected benchmarking IPC";
|
| - return;
|
| - }
|
| - request_context_->GetURLRequestContext()->
|
| - http_transaction_factory()->GetCache()->CloseAllConnections();
|
| -}
|
| -
|
| -void ChromeNetBenchmarkingMessageFilter::OnSetCacheMode(bool enabled) {
|
| - // This function is disabled unless the user has enabled
|
| - // benchmarking extensions.
|
| - if (!CheckBenchmarkingEnabled()) {
|
| - NOTREACHED() << "Received unexpected benchmarking IPC";
|
| - return;
|
| - }
|
| - net::HttpCache::Mode mode = enabled ?
|
| - net::HttpCache::NORMAL : net::HttpCache::DISABLE;
|
| - net::HttpCache* http_cache = request_context_->GetURLRequestContext()->
|
| - http_transaction_factory()->GetCache();
|
| - http_cache->set_mode(mode);
|
| -}
|
| -
|
| -void ChromeNetBenchmarkingMessageFilter::OnClearPredictorCache() {
|
| - // This function is disabled unless the user has enabled
|
| - // benchmarking extensions.
|
| - DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| - if (!CheckBenchmarkingEnabled()) {
|
| - NOTREACHED() << "Received unexpected benchmarking IPC";
|
| - return;
|
| - }
|
| - // TODO(623967): Ensure that the profile or predictor are not accessed after
|
| - // they have been shut down.
|
| - chrome_browser_net::Predictor* predictor = profile_->GetNetworkPredictor();
|
| - if (predictor)
|
| - predictor->DiscardAllResultsAndClearPrefsOnUIThread();
|
| -}
|
| -
|
| -bool ChromeNetBenchmarkingMessageFilter::CheckBenchmarkingEnabled() const {
|
| - static bool checked = false;
|
| - static bool result = false;
|
| - if (!checked) {
|
| - const base::CommandLine& command_line =
|
| - *base::CommandLine::ForCurrentProcess();
|
| - result = command_line.HasSwitch(switches::kEnableNetBenchmarking);
|
| - checked = true;
|
| - }
|
| - return result;
|
| -}
|
| -
|
|
|