| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_FILTER_MOCK_FILTER_CONTEXT_H_ | |
| 6 #define NET_FILTER_MOCK_FILTER_CONTEXT_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "net/base/net_log.h" | |
| 12 #include "net/base/sdch_manager.h" | |
| 13 #include "net/filter/filter.h" | |
| 14 #include "url/gurl.h" | |
| 15 | |
| 16 namespace net { | |
| 17 | |
| 18 class URLRequestContext; | |
| 19 | |
| 20 class MockFilterContext : public FilterContext { | |
| 21 public: | |
| 22 MockFilterContext(); | |
| 23 ~MockFilterContext() override; | |
| 24 | |
| 25 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } | |
| 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; } | |
| 31 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; } | |
| 34 void SetSdchResponse(scoped_ptr<SdchManager::DictionarySet> handle) { | |
| 35 dictionaries_handle_ = handle.Pass(); | |
| 36 } | |
| 37 URLRequestContext* GetModifiableURLRequestContext() const { | |
| 38 return context_.get(); | |
| 39 } | |
| 40 | |
| 41 // 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 | |
| 43 // of those interfaces as coding errors. | |
| 44 void NukeUnstableInterfaces(); | |
| 45 | |
| 46 bool GetMimeType(std::string* mime_type) const override; | |
| 47 | |
| 48 // What URL was used to access this data? | |
| 49 // Return false if gurl is not present. | |
| 50 bool GetURL(GURL* gurl) const override; | |
| 51 | |
| 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? | |
| 57 base::Time GetRequestTime() const override; | |
| 58 | |
| 59 // Is data supplied from cache, or fresh across the net? | |
| 60 bool IsCachedContent() const override; | |
| 61 | |
| 62 // Is this a download? | |
| 63 bool IsDownload() const override; | |
| 64 | |
| 65 // Handle to dictionaries advertised. | |
| 66 SdchManager::DictionarySet* SdchDictionariesAdvertised() const override; | |
| 67 | |
| 68 // How many bytes were fed to filter(s) so far? | |
| 69 int64 GetByteReadCount() const override; | |
| 70 | |
| 71 int GetResponseCode() const override; | |
| 72 | |
| 73 // The URLRequestContext associated with the request. | |
| 74 const URLRequestContext* GetURLRequestContext() const override; | |
| 75 | |
| 76 void RecordPacketStats(StatisticSelector statistic) const override {} | |
| 77 | |
| 78 const BoundNetLog& GetNetLog() const override; | |
| 79 | |
| 80 private: | |
| 81 std::string mime_type_; | |
| 82 std::string content_disposition_; | |
| 83 GURL gurl_; | |
| 84 base::Time request_time_; | |
| 85 bool is_cached_content_; | |
| 86 bool is_download_; | |
| 87 scoped_ptr<SdchManager::DictionarySet> dictionaries_handle_; | |
| 88 bool ok_to_call_get_url_; | |
| 89 int response_code_; | |
| 90 scoped_ptr<URLRequestContext> context_; | |
| 91 BoundNetLog net_log_; | |
| 92 | |
| 93 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); | |
| 94 }; | |
| 95 | |
| 96 } // namespace net | |
| 97 | |
| 98 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_ | |
| OLD | NEW |