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.
5 #ifndef NET_BASE_MOCK_FILTER_CONTEXT_H_
6 #define NET_BASE_MOCK_FILTER_CONTEXT_H_
10 #include "net/base/filter.h"
15 class MockFilterContext
: public FilterContext
{
18 virtual ~MockFilterContext();
20 void SetMimeType(const std::string
& mime_type
) { mime_type_
= mime_type
; }
21 void SetURL(const GURL
& gurl
) { gurl_
= gurl
; }
22 void SetRequestTime(const base::Time time
) { request_time_
= time
; }
23 void SetCached(bool is_cached
) { is_cached_content_
= is_cached
; }
24 void SetDownload(bool is_download
) { is_download_
= is_download
; }
25 void SetResponseCode(int response_code
) { response_code_
= response_code
; }
26 void SetSdchResponse(bool is_sdch_response
) {
27 is_sdch_response_
= is_sdch_response
;
30 virtual bool GetMimeType(std::string
* mime_type
) const OVERRIDE
;
32 // What URL was used to access this data?
33 // Return false if gurl is not present.
34 virtual bool GetURL(GURL
* gurl
) const OVERRIDE
;
36 // What was this data requested from a server?
37 virtual base::Time
GetRequestTime() const OVERRIDE
;
39 // Is data supplied from cache, or fresh across the net?
40 virtual bool IsCachedContent() const OVERRIDE
;
42 // Is this a download?
43 virtual bool IsDownload() const OVERRIDE
;
45 // Was this data flagged as a response to a request with an SDCH dictionary?
46 virtual bool IsSdchResponse() const OVERRIDE
;
48 // How many bytes were fed to filter(s) so far?
49 virtual int64
GetByteReadCount() const OVERRIDE
;
51 virtual int GetResponseCode() const OVERRIDE
;
53 virtual void RecordPacketStats(StatisticSelector statistic
) const OVERRIDE
{}
57 std::string mime_type_
;
59 base::Time request_time_
;
60 bool is_cached_content_
;
62 bool is_sdch_response_
;
65 DISALLOW_COPY_AND_ASSIGN(MockFilterContext
);
70 #endif // NET_BASE_MOCK_FILTER_CONTEXT_H_