| 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 "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "net/base/net_log.h" | 11 #include "net/base/net_log.h" |
| 12 #include "net/base/sdch_manager.h" | 12 #include "net/base/sdch_manager.h" |
| 13 #include "net/filter/filter.h" | 13 #include "net/filter/filter.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 class URLRequestContext; | 18 class URLRequestContext; |
| 19 | 19 |
| 20 class MockFilterContext : public FilterContext { | 20 class MockFilterContext : public FilterContext { |
| 21 public: | 21 public: |
| 22 MockFilterContext(); | 22 MockFilterContext(); |
| 23 ~MockFilterContext() override; | 23 ~MockFilterContext() override; |
| 24 | 24 |
| 25 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } | 25 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } |
| 26 void SetURL(const GURL& gurl) { gurl_ = gurl; } | 26 void SetURL(const GURL& gurl) { gurl_ = gurl; } |
| 27 void SetContentDisposition(const std::string& disposition) { | |
| 28 content_disposition_ = disposition; | |
| 29 } | |
| 30 void SetRequestTime(const base::Time time) { request_time_ = time; } | 27 void SetRequestTime(const base::Time time) { request_time_ = time; } |
| 31 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } | 28 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } |
| 32 void SetDownload(bool is_download) { is_download_ = is_download; } | |
| 33 void SetResponseCode(int response_code) { response_code_ = response_code; } | 29 void SetResponseCode(int response_code) { response_code_ = response_code; } |
| 34 void SetSdchResponse(scoped_ptr<SdchManager::DictionarySet> handle) { | 30 void SetSdchResponse(scoped_ptr<SdchManager::DictionarySet> handle) { |
| 35 dictionaries_handle_ = handle.Pass(); | 31 dictionaries_handle_ = handle.Pass(); |
| 36 } | 32 } |
| 37 URLRequestContext* GetModifiableURLRequestContext() const { | 33 URLRequestContext* GetModifiableURLRequestContext() const { |
| 38 return context_.get(); | 34 return context_.get(); |
| 39 } | 35 } |
| 40 | 36 |
| 41 // After a URLRequest's destructor is called, some interfaces may become | 37 // After a URLRequest's destructor is called, some interfaces may become |
| 42 // unstable. This method is used to signal that state, so we can tag use | 38 // unstable. This method is used to signal that state, so we can tag use |
| 43 // of those interfaces as coding errors. | 39 // of those interfaces as coding errors. |
| 44 void NukeUnstableInterfaces(); | 40 void NukeUnstableInterfaces(); |
| 45 | 41 |
| 46 bool GetMimeType(std::string* mime_type) const override; | 42 bool GetMimeType(std::string* mime_type) const override; |
| 47 | 43 |
| 48 // What URL was used to access this data? | 44 // What URL was used to access this data? |
| 49 // Return false if gurl is not present. | 45 // Return false if gurl is not present. |
| 50 bool GetURL(GURL* gurl) const override; | 46 bool GetURL(GURL* gurl) const override; |
| 51 | 47 |
| 52 // What Content-Disposition did the server supply for this data? | |
| 53 // Return false if Content-Disposition was not present. | |
| 54 bool GetContentDisposition(std::string* disposition) const override; | |
| 55 | |
| 56 // What was this data requested from a server? | 48 // What was this data requested from a server? |
| 57 base::Time GetRequestTime() const override; | 49 base::Time GetRequestTime() const override; |
| 58 | 50 |
| 59 // Is data supplied from cache, or fresh across the net? | 51 // Is data supplied from cache, or fresh across the net? |
| 60 bool IsCachedContent() const override; | 52 bool IsCachedContent() const override; |
| 61 | 53 |
| 62 // Is this a download? | |
| 63 bool IsDownload() const override; | |
| 64 | |
| 65 // Handle to dictionaries advertised. | 54 // Handle to dictionaries advertised. |
| 66 SdchManager::DictionarySet* SdchDictionariesAdvertised() const override; | 55 SdchManager::DictionarySet* SdchDictionariesAdvertised() const override; |
| 67 | 56 |
| 68 // How many bytes were fed to filter(s) so far? | 57 // How many bytes were fed to filter(s) so far? |
| 69 int64 GetByteReadCount() const override; | 58 int64 GetByteReadCount() const override; |
| 70 | 59 |
| 71 int GetResponseCode() const override; | 60 int GetResponseCode() const override; |
| 72 | 61 |
| 73 // The URLRequestContext associated with the request. | 62 // The URLRequestContext associated with the request. |
| 74 const URLRequestContext* GetURLRequestContext() const override; | 63 const URLRequestContext* GetURLRequestContext() const override; |
| 75 | 64 |
| 76 void RecordPacketStats(StatisticSelector statistic) const override {} | 65 void RecordPacketStats(StatisticSelector statistic) const override {} |
| 77 | 66 |
| 78 const BoundNetLog& GetNetLog() const override; | 67 const BoundNetLog& GetNetLog() const override; |
| 79 | 68 |
| 80 private: | 69 private: |
| 81 std::string mime_type_; | 70 std::string mime_type_; |
| 82 std::string content_disposition_; | |
| 83 GURL gurl_; | 71 GURL gurl_; |
| 84 base::Time request_time_; | 72 base::Time request_time_; |
| 85 bool is_cached_content_; | 73 bool is_cached_content_; |
| 86 bool is_download_; | |
| 87 scoped_ptr<SdchManager::DictionarySet> dictionaries_handle_; | 74 scoped_ptr<SdchManager::DictionarySet> dictionaries_handle_; |
| 88 bool ok_to_call_get_url_; | 75 bool ok_to_call_get_url_; |
| 89 int response_code_; | 76 int response_code_; |
| 90 scoped_ptr<URLRequestContext> context_; | 77 scoped_ptr<URLRequestContext> context_; |
| 91 BoundNetLog net_log_; | 78 BoundNetLog net_log_; |
| 92 | 79 |
| 93 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); | 80 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); |
| 94 }; | 81 }; |
| 95 | 82 |
| 96 } // namespace net | 83 } // namespace net |
| 97 | 84 |
| 98 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_ | 85 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_ |
| OLD | NEW |