1// Copyright (c) 2011 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. 4 5#ifndef CHROME_BROWSER_CHROME_NET_BENCHMARKING_MESSAGE_FILTER_H_ 6#define CHROME_BROWSER_CHROME_NET_BENCHMARKING_MESSAGE_FILTER_H_ 7 8#include "content/public/browser/browser_message_filter.h" 9 10namespace net { 11class URLRequestContextGetter; 12} 13 14class Profile; 15 16// This class filters out incoming Chrome-specific benchmarking IPC messages 17// for the renderer process on the IPC thread. 18class ChromeNetBenchmarkingMessageFilter 19 : public content::BrowserMessageFilter { 20 public: 21 ChromeNetBenchmarkingMessageFilter( 22 Profile* profile, 23 net::URLRequestContextGetter* request_context); 24 25 // content::BrowserMessageFilter methods: 26 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 27 28 private: 29 virtual ~ChromeNetBenchmarkingMessageFilter(); 30 31 // Message handlers. 32 void OnCloseCurrentConnections(); 33 void OnClearCache(IPC::Message* reply_msg); 34 void OnClearHostResolverCache(int* result); 35 void OnSetCacheMode(bool enabled); 36 void OnClearPredictorCache(int* result); 37 38 // Returns true if benchmarking is enabled for chrome. 39 bool CheckBenchmarkingEnabled() const; 40 41 // The Profile associated with our renderer process. This should only be 42 // accessed on the UI thread! 43 Profile* profile_; 44 scoped_refptr<net::URLRequestContextGetter> request_context_; 45 46 DISALLOW_COPY_AND_ASSIGN(ChromeNetBenchmarkingMessageFilter); 47}; 48 49#endif // CHROME_BROWSER_CHROME_NET_BENCHMARKING_MESSAGE_FILTER_H_ 50 51