| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 | 5 |
| 6 #ifndef NET_BASE_FILTER_UNITTEST_H_ | 6 #ifndef NET_BASE_FILTER_UNITTEST_H_ |
| 7 #define NET_BASE_FILTER_UNITTEST_H_ | 7 #define NET_BASE_FILTER_UNITTEST_H_ |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 12 #include "net/base/filter.h" | 12 #include "net/base/filter.h" |
| 13 | 13 |
| 14 //------------------------------------------------------------------------------ | 14 //------------------------------------------------------------------------------ |
| 15 class MockFilterContext : public FilterContext { | 15 class MockFilterContext : public FilterContext { |
| 16 public: | 16 public: |
| 17 explicit MockFilterContext(int buffer_size) | 17 explicit MockFilterContext(int buffer_size) |
| 18 : buffer_size_(buffer_size), | 18 : buffer_size_(buffer_size), |
| 19 is_cached_content_(false), | 19 is_cached_content_(false), |
| 20 is_sdch_response_(false) { | 20 is_sdch_response_(false) { |
| 21 } | 21 } |
| 22 | 22 |
| 23 void SetBufferSize(int buffer_size) { buffer_size_ = buffer_size; } | 23 void SetBufferSize(int buffer_size) { buffer_size_ = buffer_size; } |
| 24 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } | 24 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } |
| 25 void SetURL(const GURL& gurl) { gurl_ = gurl; } | 25 void SetURL(const GURL& gurl) { gurl_ = gurl; } |
| 26 void SetRequestTime(const base::Time time) { request_time_ = time; } | 26 void SetRequestTime(const base::Time time) { request_time_ = time; } |
| 27 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } | 27 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } |
| 28 void SetSdchResponse(bool is_sdch_response) { | 28 void SetSdchResponse(bool is_sdch_response) { |
| 29 is_sdch_response = is_sdch_response; | 29 is_sdch_response_ = is_sdch_response; |
| 30 } | 30 } |
| 31 | 31 |
| 32 virtual bool GetMimeType(std::string* mime_type) const { | 32 virtual bool GetMimeType(std::string* mime_type) const { |
| 33 *mime_type = mime_type_; | 33 *mime_type = mime_type_; |
| 34 return true; | 34 return true; |
| 35 } | 35 } |
| 36 | 36 |
| 37 // What URL was used to access this data? | 37 // What URL was used to access this data? |
| 38 // Return false if gurl is not present. | 38 // Return false if gurl is not present. |
| 39 virtual bool GetURL(GURL* gurl) const { | 39 virtual bool GetURL(GURL* gurl) const { |
| 40 *gurl = gurl_; | 40 *gurl = gurl_; |
| 41 return true; | 41 return true; |
| 42 } | 42 } |
| 43 | 43 |
| 44 // What was this data requested from a server? | 44 // What was this data requested from a server? |
| 45 virtual base::Time GetRequestTime() const { | 45 virtual base::Time GetRequestTime() const { |
| 46 return request_time_; | 46 return request_time_; |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Is data supplied from cache, or fresh across the net? | 49 // Is data supplied from cache, or fresh across the net? |
| 50 virtual bool IsCachedContent() const { return is_cached_content_; } | 50 virtual bool IsCachedContent() const { return is_cached_content_; } |
| 51 | 51 |
| 52 // 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? |
| 53 virtual bool IsSdchResponse() const { return is_sdch_response_; } | 53 virtual bool IsSdchResponse() const { return is_sdch_response_; } |
| 54 | 54 |
| 55 // How many bytes were fed to filter(s) so far? |
| 56 virtual int64 GetByteReadCount() const { return 0; } |
| 57 |
| 55 // What is the desirable input buffer size for these filters? | 58 // What is the desirable input buffer size for these filters? |
| 56 virtual int GetInputStreambufferSize() const { return buffer_size_; } | 59 virtual int GetInputStreamBufferSize() const { return buffer_size_; } |
| 57 | 60 |
| 58 | 61 |
| 59 private: | 62 private: |
| 60 int buffer_size_; | 63 int buffer_size_; |
| 61 std::string mime_type_; | 64 std::string mime_type_; |
| 62 GURL gurl_; | 65 GURL gurl_; |
| 63 base::Time request_time_; | 66 base::Time request_time_; |
| 64 bool is_cached_content_; | 67 bool is_cached_content_; |
| 65 bool is_sdch_response_; | 68 bool is_sdch_response_; |
| 66 | 69 |
| 67 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); | 70 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); |
| 68 }; | 71 }; |
| 69 | 72 |
| 70 #endif // NET_BASE_FILTER_UNITTEST_H_ | 73 #endif // NET_BASE_FILTER_UNITTEST_H_ |
| OLD | NEW |