| 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 #include "net/filter/mock_filter_context.h" | 5 #include "net/filter/mock_filter_context.h" |
| 6 | 6 |
| 7 #include "net/url_request/url_request_context.h" | 7 #include "net/url_request/url_request_context.h" |
| 8 | 8 |
| 9 namespace net { | 9 namespace net { |
| 10 | 10 |
| 11 MockFilterContext::MockFilterContext() | 11 MockFilterContext::MockFilterContext() |
| 12 : is_cached_content_(false), | 12 : is_cached_content_(false), |
| 13 is_download_(false), | |
| 14 ok_to_call_get_url_(true), | 13 ok_to_call_get_url_(true), |
| 15 response_code_(-1), | 14 response_code_(-1), |
| 16 context_(new URLRequestContext()) { | 15 context_(new URLRequestContext()) { |
| 17 } | 16 } |
| 18 | 17 |
| 19 MockFilterContext::~MockFilterContext() {} | 18 MockFilterContext::~MockFilterContext() {} |
| 20 | 19 |
| 21 void MockFilterContext::NukeUnstableInterfaces() { | 20 void MockFilterContext::NukeUnstableInterfaces() { |
| 22 context_.reset(); | 21 context_.reset(); |
| 23 ok_to_call_get_url_ = false; | 22 ok_to_call_get_url_ = false; |
| 24 request_time_ = base::Time(); | 23 request_time_ = base::Time(); |
| 25 } | 24 } |
| 26 | 25 |
| 27 bool MockFilterContext::GetMimeType(std::string* mime_type) const { | 26 bool MockFilterContext::GetMimeType(std::string* mime_type) const { |
| 28 *mime_type = mime_type_; | 27 *mime_type = mime_type_; |
| 29 return true; | 28 return true; |
| 30 } | 29 } |
| 31 | 30 |
| 32 // What URL was used to access this data? | 31 // What URL was used to access this data? |
| 33 // Return false if gurl is not present. | 32 // Return false if gurl is not present. |
| 34 bool MockFilterContext::GetURL(GURL* gurl) const { | 33 bool MockFilterContext::GetURL(GURL* gurl) const { |
| 35 DCHECK(ok_to_call_get_url_); | 34 DCHECK(ok_to_call_get_url_); |
| 36 *gurl = gurl_; | 35 *gurl = gurl_; |
| 37 return true; | 36 return true; |
| 38 } | 37 } |
| 39 | 38 |
| 40 bool MockFilterContext::GetContentDisposition(std::string* disposition) const { | |
| 41 if (content_disposition_.empty()) | |
| 42 return false; | |
| 43 *disposition = content_disposition_; | |
| 44 return true; | |
| 45 } | |
| 46 | |
| 47 // What was this data requested from a server? | 39 // What was this data requested from a server? |
| 48 base::Time MockFilterContext::GetRequestTime() const { | 40 base::Time MockFilterContext::GetRequestTime() const { |
| 49 return request_time_; | 41 return request_time_; |
| 50 } | 42 } |
| 51 | 43 |
| 52 bool MockFilterContext::IsCachedContent() const { return is_cached_content_; } | 44 bool MockFilterContext::IsCachedContent() const { return is_cached_content_; } |
| 53 | 45 |
| 54 bool MockFilterContext::IsDownload() const { return is_download_; } | |
| 55 | |
| 56 SdchManager::DictionarySet* | 46 SdchManager::DictionarySet* |
| 57 MockFilterContext::SdchDictionariesAdvertised() const { | 47 MockFilterContext::SdchDictionariesAdvertised() const { |
| 58 return dictionaries_handle_.get(); | 48 return dictionaries_handle_.get(); |
| 59 } | 49 } |
| 60 | 50 |
| 61 int64 MockFilterContext::GetByteReadCount() const { return 0; } | 51 int64 MockFilterContext::GetByteReadCount() const { return 0; } |
| 62 | 52 |
| 63 int MockFilterContext::GetResponseCode() const { return response_code_; } | 53 int MockFilterContext::GetResponseCode() const { return response_code_; } |
| 64 | 54 |
| 65 const URLRequestContext* MockFilterContext::GetURLRequestContext() const { | 55 const URLRequestContext* MockFilterContext::GetURLRequestContext() const { |
| 66 return context_.get(); | 56 return context_.get(); |
| 67 } | 57 } |
| 68 | 58 |
| 69 const BoundNetLog& MockFilterContext::GetNetLog() const { | 59 const BoundNetLog& MockFilterContext::GetNetLog() const { |
| 70 return net_log_; | 60 return net_log_; |
| 71 } | 61 } |
| 72 | 62 |
| 73 } // namespace net | 63 } // namespace net |
| OLD | NEW |