OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_FILTER_MOCK_FILTER_CONTEXT_H_ | 5 #ifndef NET_FILTER_MOCK_FILTER_CONTEXT_H_ |
6 #define NET_FILTER_MOCK_FILTER_CONTEXT_H_ | 6 #define NET_FILTER_MOCK_FILTER_CONTEXT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "net/filter/filter.h" | 10 #include "net/filter/filter.h" |
11 #include "url/gurl.h" | 11 #include "url/gurl.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 class MockFilterContext : public FilterContext { | 15 class MockFilterContext : public FilterContext { |
16 public: | 16 public: |
17 MockFilterContext(); | 17 MockFilterContext(); |
18 virtual ~MockFilterContext(); | 18 virtual ~MockFilterContext(); |
19 | 19 |
20 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } | 20 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } |
21 void SetURL(const GURL& gurl) { gurl_ = gurl; } | 21 void SetURL(const GURL& gurl) { gurl_ = gurl; } |
| 22 void SetContentDisposition(const std::string& disposition) { |
| 23 content_disposition_ = disposition; |
| 24 } |
22 void SetRequestTime(const base::Time time) { request_time_ = time; } | 25 void SetRequestTime(const base::Time time) { request_time_ = time; } |
23 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } | 26 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } |
24 void SetDownload(bool is_download) { is_download_ = is_download; } | 27 void SetDownload(bool is_download) { is_download_ = is_download; } |
25 void SetResponseCode(int response_code) { response_code_ = response_code; } | 28 void SetResponseCode(int response_code) { response_code_ = response_code; } |
26 void SetSdchResponse(bool is_sdch_response) { | 29 void SetSdchResponse(bool is_sdch_response) { |
27 is_sdch_response_ = is_sdch_response; | 30 is_sdch_response_ = is_sdch_response; |
28 } | 31 } |
29 | 32 |
30 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 33 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
31 | 34 |
32 // What URL was used to access this data? | 35 // What URL was used to access this data? |
33 // Return false if gurl is not present. | 36 // Return false if gurl is not present. |
34 virtual bool GetURL(GURL* gurl) const OVERRIDE; | 37 virtual bool GetURL(GURL* gurl) const OVERRIDE; |
35 | 38 |
| 39 // What Content-Disposition did the server supply for this data? |
| 40 // Return false if Content-Disposition was not present. |
| 41 virtual bool GetContentDisposition(std::string* disposition) const OVERRIDE; |
| 42 |
36 // What was this data requested from a server? | 43 // What was this data requested from a server? |
37 virtual base::Time GetRequestTime() const OVERRIDE; | 44 virtual base::Time GetRequestTime() const OVERRIDE; |
38 | 45 |
39 // Is data supplied from cache, or fresh across the net? | 46 // Is data supplied from cache, or fresh across the net? |
40 virtual bool IsCachedContent() const OVERRIDE; | 47 virtual bool IsCachedContent() const OVERRIDE; |
41 | 48 |
42 // Is this a download? | 49 // Is this a download? |
43 virtual bool IsDownload() const OVERRIDE; | 50 virtual bool IsDownload() const OVERRIDE; |
44 | 51 |
45 // Was this data flagged as a response to a request with an SDCH dictionary? | 52 // Was this data flagged as a response to a request with an SDCH dictionary? |
46 virtual bool IsSdchResponse() const OVERRIDE; | 53 virtual bool IsSdchResponse() const OVERRIDE; |
47 | 54 |
48 // How many bytes were fed to filter(s) so far? | 55 // How many bytes were fed to filter(s) so far? |
49 virtual int64 GetByteReadCount() const OVERRIDE; | 56 virtual int64 GetByteReadCount() const OVERRIDE; |
50 | 57 |
51 virtual int GetResponseCode() const OVERRIDE; | 58 virtual int GetResponseCode() const OVERRIDE; |
52 | 59 |
53 virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE {} | 60 virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE {} |
54 | 61 |
55 private: | 62 private: |
56 int buffer_size_; | 63 int buffer_size_; |
57 std::string mime_type_; | 64 std::string mime_type_; |
| 65 std::string content_disposition_; |
58 GURL gurl_; | 66 GURL gurl_; |
59 base::Time request_time_; | 67 base::Time request_time_; |
60 bool is_cached_content_; | 68 bool is_cached_content_; |
61 bool is_download_; | 69 bool is_download_; |
62 bool is_sdch_response_; | 70 bool is_sdch_response_; |
63 int response_code_; | 71 int response_code_; |
64 | 72 |
65 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); | 73 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); |
66 }; | 74 }; |
67 | 75 |
68 } // namespace net | 76 } // namespace net |
69 | 77 |
70 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_ | 78 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_ |
OLD | NEW |