| 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 SetFilename(const std::string& filename) { filename_ = filename; } |
| 22 void SetRequestTime(const base::Time time) { request_time_ = time; } | 23 void SetRequestTime(const base::Time time) { request_time_ = time; } |
| 23 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } | 24 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } |
| 24 void SetDownload(bool is_download) { is_download_ = is_download; } | 25 void SetDownload(bool is_download) { is_download_ = is_download; } |
| 25 void SetResponseCode(int response_code) { response_code_ = response_code; } | 26 void SetResponseCode(int response_code) { response_code_ = response_code; } |
| 26 void SetSdchResponse(bool is_sdch_response) { | 27 void SetSdchResponse(bool is_sdch_response) { |
| 27 is_sdch_response_ = is_sdch_response; | 28 is_sdch_response_ = is_sdch_response; |
| 28 } | 29 } |
| 29 | 30 |
| 30 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 31 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
| 31 | 32 |
| 32 // What URL was used to access this data? | 33 // What URL was used to access this data? |
| 33 // Return false if gurl is not present. | 34 // Return false if gurl is not present. |
| 34 virtual bool GetURL(GURL* gurl) const OVERRIDE; | 35 virtual bool GetURL(GURL* gurl) const OVERRIDE; |
| 35 | 36 |
| 37 // What filename did the server say to use for this data? |
| 38 // Return false if filename is not present. |
| 39 virtual bool GetFilename(std::string* filename) const OVERRIDE; |
| 40 |
| 36 // What was this data requested from a server? | 41 // What was this data requested from a server? |
| 37 virtual base::Time GetRequestTime() const OVERRIDE; | 42 virtual base::Time GetRequestTime() const OVERRIDE; |
| 38 | 43 |
| 39 // Is data supplied from cache, or fresh across the net? | 44 // Is data supplied from cache, or fresh across the net? |
| 40 virtual bool IsCachedContent() const OVERRIDE; | 45 virtual bool IsCachedContent() const OVERRIDE; |
| 41 | 46 |
| 42 // Is this a download? | 47 // Is this a download? |
| 43 virtual bool IsDownload() const OVERRIDE; | 48 virtual bool IsDownload() const OVERRIDE; |
| 44 | 49 |
| 45 // Was this data flagged as a response to a request with an SDCH dictionary? | 50 // Was this data flagged as a response to a request with an SDCH dictionary? |
| 46 virtual bool IsSdchResponse() const OVERRIDE; | 51 virtual bool IsSdchResponse() const OVERRIDE; |
| 47 | 52 |
| 48 // How many bytes were fed to filter(s) so far? | 53 // How many bytes were fed to filter(s) so far? |
| 49 virtual int64 GetByteReadCount() const OVERRIDE; | 54 virtual int64 GetByteReadCount() const OVERRIDE; |
| 50 | 55 |
| 51 virtual int GetResponseCode() const OVERRIDE; | 56 virtual int GetResponseCode() const OVERRIDE; |
| 52 | 57 |
| 53 virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE {} | 58 virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE {} |
| 54 | 59 |
| 55 private: | 60 private: |
| 56 int buffer_size_; | 61 int buffer_size_; |
| 57 std::string mime_type_; | 62 std::string mime_type_; |
| 63 std::string filename_; |
| 58 GURL gurl_; | 64 GURL gurl_; |
| 59 base::Time request_time_; | 65 base::Time request_time_; |
| 60 bool is_cached_content_; | 66 bool is_cached_content_; |
| 61 bool is_download_; | 67 bool is_download_; |
| 62 bool is_sdch_response_; | 68 bool is_sdch_response_; |
| 63 int response_code_; | 69 int response_code_; |
| 64 | 70 |
| 65 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); | 71 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); |
| 66 }; | 72 }; |
| 67 | 73 |
| 68 } // namespace net | 74 } // namespace net |
| 69 | 75 |
| 70 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_ | 76 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_ |
| OLD | NEW |