Probably broke Win7 Tests (dbg)(6). http://build.chromium.org/p/chromium.win/builders...
[chromium-blink-merge.git] / net / filter / mock_filter_context.h
blob9bb6235a3a9ab161c08880e1421c9b574078d33b
1 // Copyright 2014 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_FILTER_MOCK_FILTER_CONTEXT_H_
6 #define NET_FILTER_MOCK_FILTER_CONTEXT_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "net/filter/filter.h"
12 #include "url/gurl.h"
14 namespace net {
16 class URLRequestContext;
18 class MockFilterContext : public FilterContext {
19 public:
20 MockFilterContext();
21 virtual ~MockFilterContext();
23 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; }
24 void SetURL(const GURL& gurl) { gurl_ = gurl; }
25 void SetContentDisposition(const std::string& disposition) {
26 content_disposition_ = disposition;
28 void SetRequestTime(const base::Time time) { request_time_ = time; }
29 void SetCached(bool is_cached) { is_cached_content_ = is_cached; }
30 void SetDownload(bool is_download) { is_download_ = is_download; }
31 void SetResponseCode(int response_code) { response_code_ = response_code; }
32 void SetSdchResponse(bool is_sdch_response) {
33 is_sdch_response_ = is_sdch_response;
35 URLRequestContext* GetModifiableURLRequestContext() const {
36 return context_.get();
39 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE;
41 // What URL was used to access this data?
42 // Return false if gurl is not present.
43 virtual bool GetURL(GURL* gurl) const OVERRIDE;
45 // What Content-Disposition did the server supply for this data?
46 // Return false if Content-Disposition was not present.
47 virtual bool GetContentDisposition(std::string* disposition) const OVERRIDE;
49 // What was this data requested from a server?
50 virtual base::Time GetRequestTime() const OVERRIDE;
52 // Is data supplied from cache, or fresh across the net?
53 virtual bool IsCachedContent() const OVERRIDE;
55 // Is this a download?
56 virtual bool IsDownload() const OVERRIDE;
58 // Was this data flagged as a response to a request with an SDCH dictionary?
59 virtual bool IsSdchResponse() const OVERRIDE;
61 // How many bytes were fed to filter(s) so far?
62 virtual int64 GetByteReadCount() const OVERRIDE;
64 virtual int GetResponseCode() const OVERRIDE;
66 // The URLRequestContext associated with the request.
67 virtual const URLRequestContext* GetURLRequestContext() const OVERRIDE;
69 virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE {}
71 private:
72 int buffer_size_;
73 std::string mime_type_;
74 std::string content_disposition_;
75 GURL gurl_;
76 base::Time request_time_;
77 bool is_cached_content_;
78 bool is_download_;
79 bool is_sdch_response_;
80 int response_code_;
81 scoped_ptr<URLRequestContext> context_;
83 DISALLOW_COPY_AND_ASSIGN(MockFilterContext);
86 } // namespace net
88 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_