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

Unified Diff: chrome/browser/chrome_benchmarking_message_filter.cc

Issue 11801024: Fixed browser crash when using Debug build: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed failure on win perf bot. Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chrome_benchmarking_message_filter.cc
diff --git a/chrome/browser/chrome_benchmarking_message_filter.cc b/chrome/browser/chrome_benchmarking_message_filter.cc
deleted file mode 100644
index 5be4df1abc3d10747f780f65037c2453eba58e6b..0000000000000000000000000000000000000000
--- a/chrome/browser/chrome_benchmarking_message_filter.cc
+++ /dev/null
@@ -1,169 +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_benchmarking_message_filter.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/command_line.h"
-#include "base/memory/scoped_ptr.h"
-#include "chrome/browser/net/chrome_url_request_context.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/host_cache.h"
-#include "net/base/host_resolver.h"
-#include "net/base/net_errors.h"
-#include "net/disk_cache/disk_cache.h"
-#include "net/http/http_cache.h"
-#include "net/http/http_network_layer.h"
-#include "net/http/http_stream_factory.h"
-
-namespace {
-
-void ClearCacheCallback(ChromeBenchmarkingMessageFilter* filter,
- IPC::Message* reply_msg,
- int result) {
- ChromeViewHostMsg_ClearCache::WriteReplyParams(reply_msg, result);
- filter->Send(reply_msg);
-}
-
-} // namespace
-
-ChromeBenchmarkingMessageFilter::ChromeBenchmarkingMessageFilter(
- int render_process_id,
- Profile* profile,
- net::URLRequestContextGetter* request_context)
- : render_process_id_(render_process_id),
- profile_(profile),
- request_context_(request_context) {
-}
-
-ChromeBenchmarkingMessageFilter::~ChromeBenchmarkingMessageFilter() {
-}
-
-bool ChromeBenchmarkingMessageFilter::OnMessageReceived(
- const IPC::Message& message, bool* message_was_ok) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP_EX(ChromeBenchmarkingMessageFilter, message,
- *message_was_ok)
- IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CloseCurrentConnections,
- OnCloseCurrentConnections)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_ClearCache, OnClearCache)
- IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ClearHostResolverCache,
- OnClearHostResolverCache)
- IPC_MESSAGE_HANDLER(ChromeViewHostMsg_EnableSpdy, OnEnableSpdy)
- IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ClearPredictorCache,
- OnClearPredictorCache)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP_EX()
- return handled;
-}
-
-void ChromeBenchmarkingMessageFilter::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, make_scoped_refptr(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 ChromeBenchmarkingMessageFilter::OnClearHostResolverCache(int* result) {
- // This function is disabled unless the user has enabled
- // benchmarking extensions.
- if (!CheckBenchmarkingEnabled()) {
- NOTREACHED() << "Received unexpected benchmarking IPC";
- return;
- }
- *result = -1;
- net::HostCache* cache =
- request_context_->GetURLRequestContext()->host_resolver()->GetHostCache();
- if (cache) {
- cache->clear();
- *result = 0;
- }
-}
-
-// TODO(lzheng): This only enables spdy over ssl. Enable spdy for http
-// when needed.
-void ChromeBenchmarkingMessageFilter::OnEnableSpdy(bool enable) {
- // This function is disabled unless the user has enabled
- // benchmarking extensions.
- if (!CheckBenchmarkingEnabled()) {
- NOTREACHED() << "Received unexpected benchmarking IPC";
- return;
- }
- if (enable) {
- net::HttpStreamFactory::EnableNpnSpdy();
- net::HttpNetworkLayer::ForceAlternateProtocol();
- } else {
- net::HttpStreamFactory::EnableNpnHttpOnly();
- }
-}
-
-void ChromeBenchmarkingMessageFilter::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 ChromeBenchmarkingMessageFilter::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 ChromeBenchmarkingMessageFilter::OnClearPredictorCache(int* result) {
- // This function is disabled unless the user has enabled
- // benchmarking extensions.
- if (!CheckBenchmarkingEnabled()) {
- NOTREACHED() << "Received unexpected benchmarking IPC";
- return;
- }
- chrome_browser_net::Predictor* predictor = profile_->GetNetworkPredictor();
- if (predictor)
- predictor->DiscardAllResults();
- *result = 0;
-}
-
-bool ChromeBenchmarkingMessageFilter::CheckBenchmarkingEnabled() const {
- static bool checked = false;
- static bool result = false;
- if (!checked) {
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- result = command_line.HasSwitch(switches::kEnableBenchmarking);
- checked = true;
- }
- return result;
-}
« no previous file with comments | « chrome/browser/chrome_benchmarking_message_filter.h ('k') | chrome/browser/chrome_content_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698