OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 // |
| 5 |
| 6 #ifndef NET_BASE_FILTER_UNITTEST_H_ |
| 7 #define NET_BASE_FILTER_UNITTEST_H_ |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "googleurl/src/gurl.h" |
| 12 #include "net/base/filter.h" |
| 13 |
| 14 //------------------------------------------------------------------------------ |
| 15 class MockFilterContext : public FilterContext { |
| 16 public: |
| 17 explicit MockFilterContext(int buffer_size) : buffer_size_(buffer_size) {} |
| 18 |
| 19 void SetBufferSize(int buffer_size) { buffer_size_ = buffer_size; } |
| 20 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } |
| 21 void SetURL(const GURL& gurl) { gurl_ = gurl; } |
| 22 void SetRequestTime(const base::Time time) { request_time_ = time; } |
| 23 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } |
| 24 void SetSdchResponse(bool is_sdch_response) { |
| 25 is_sdch_response = is_sdch_response; |
| 26 } |
| 27 |
| 28 virtual bool GetMimeType(std::string* mime_type) const { |
| 29 *mime_type = mime_type_; |
| 30 return true; |
| 31 } |
| 32 |
| 33 // What URL was used to access this data? |
| 34 // Return false if gurl is not present. |
| 35 virtual bool GetURL(GURL* gurl) const { |
| 36 *gurl = gurl_; |
| 37 return true; |
| 38 } |
| 39 |
| 40 // What was this data requested from a server? |
| 41 virtual base::Time GetRequestTime() const { |
| 42 return request_time_; |
| 43 } |
| 44 |
| 45 // Is data supplied from cache, or fresh across the net? |
| 46 virtual bool IsCachedContent() const { return is_cached_content_; } |
| 47 |
| 48 // Was this data flagged as a response to a request with an SDCH dictionary? |
| 49 virtual bool IsSdchResponse() const { return is_sdch_response_; } |
| 50 |
| 51 // What is the desirable input buffer size for these filters? |
| 52 virtual int GetInputStreambufferSize() const { return buffer_size_; } |
| 53 |
| 54 |
| 55 private: |
| 56 int buffer_size_; |
| 57 std::string mime_type_; |
| 58 GURL gurl_; |
| 59 base::Time request_time_; |
| 60 bool is_cached_content_; |
| 61 bool is_sdch_response_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); |
| 64 }; |
| 65 |
| 66 #endif // NET_BASE_FILTER_UNITTEST_H_ |
OLD | NEW |