| 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 response_code_(-1) { |
| 21 } | 22 } |
| 22 | 23 |
| 23 void SetBufferSize(int buffer_size) { buffer_size_ = buffer_size; } | 24 void SetBufferSize(int buffer_size) { buffer_size_ = buffer_size; } |
| 24 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } | 25 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } |
| 25 void SetURL(const GURL& gurl) { gurl_ = gurl; } | 26 void SetURL(const GURL& gurl) { gurl_ = gurl; } |
| 26 void SetRequestTime(const base::Time time) { request_time_ = time; } | 27 void SetRequestTime(const base::Time time) { request_time_ = time; } |
| 27 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } | 28 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } |
| 29 void SetResponseCode(int response_code) { response_code_ = response_code; } |
| 28 void SetSdchResponse(bool is_sdch_response) { | 30 void SetSdchResponse(bool is_sdch_response) { |
| 29 is_sdch_response_ = is_sdch_response; | 31 is_sdch_response_ = is_sdch_response; |
| 30 } | 32 } |
| 31 | 33 |
| 32 virtual bool GetMimeType(std::string* mime_type) const { | 34 virtual bool GetMimeType(std::string* mime_type) const { |
| 33 *mime_type = mime_type_; | 35 *mime_type = mime_type_; |
| 34 return true; | 36 return true; |
| 35 } | 37 } |
| 36 | 38 |
| 37 // What URL was used to access this data? | 39 // What URL was used to access this data? |
| (...skipping 10 matching lines...) Expand all Loading... |
| 48 | 50 |
| 49 // Is data supplied from cache, or fresh across the net? | 51 // Is data supplied from cache, or fresh across the net? |
| 50 virtual bool IsCachedContent() const { return is_cached_content_; } | 52 virtual bool IsCachedContent() const { return is_cached_content_; } |
| 51 | 53 |
| 52 // Was this data flagged as a response to a request with an SDCH dictionary? | 54 // Was this data flagged as a response to a request with an SDCH dictionary? |
| 53 virtual bool IsSdchResponse() const { return is_sdch_response_; } | 55 virtual bool IsSdchResponse() const { return is_sdch_response_; } |
| 54 | 56 |
| 55 // How many bytes were fed to filter(s) so far? | 57 // How many bytes were fed to filter(s) so far? |
| 56 virtual int64 GetByteReadCount() const { return 0; } | 58 virtual int64 GetByteReadCount() const { return 0; } |
| 57 | 59 |
| 60 virtual int GetResponseCode() const { return response_code_; } |
| 61 |
| 58 // What is the desirable input buffer size for these filters? | 62 // What is the desirable input buffer size for these filters? |
| 59 virtual int GetInputStreamBufferSize() const { return buffer_size_; } | 63 virtual int GetInputStreamBufferSize() const { return buffer_size_; } |
| 60 | 64 |
| 61 | 65 |
| 62 private: | 66 private: |
| 63 int buffer_size_; | 67 int buffer_size_; |
| 64 std::string mime_type_; | 68 std::string mime_type_; |
| 65 GURL gurl_; | 69 GURL gurl_; |
| 66 base::Time request_time_; | 70 base::Time request_time_; |
| 67 bool is_cached_content_; | 71 bool is_cached_content_; |
| 68 bool is_sdch_response_; | 72 bool is_sdch_response_; |
| 73 int response_code_; |
| 69 | 74 |
| 70 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); | 75 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); |
| 71 }; | 76 }; |
| 72 | 77 |
| 73 #endif // NET_BASE_FILTER_UNITTEST_H_ | 78 #endif // NET_BASE_FILTER_UNITTEST_H_ |
| OLD | NEW |