• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "net/filter/mock_filter_context.h"
6 
7 #include "net/url_request/url_request_context.h"
8 
9 namespace net {
10 
MockFilterContext()11 MockFilterContext::MockFilterContext()
12     : is_cached_content_(false),
13       is_download_(false),
14       is_sdch_response_(false),
15       ok_to_call_get_url_(true),
16       response_code_(-1),
17       context_(new URLRequestContext()) {
18 }
19 
~MockFilterContext()20 MockFilterContext::~MockFilterContext() {}
21 
NukeUnstableInterfaces()22 void MockFilterContext::NukeUnstableInterfaces() {
23   context_.reset();
24   ok_to_call_get_url_ = false;
25   request_time_ = base::Time();
26 }
27 
GetMimeType(std::string * mime_type) const28 bool MockFilterContext::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.
GetURL(GURL * gurl) const35 bool MockFilterContext::GetURL(GURL* gurl) const {
36   DCHECK(ok_to_call_get_url_);
37   *gurl = gurl_;
38   return true;
39 }
40 
GetContentDisposition(std::string * disposition) const41 bool MockFilterContext::GetContentDisposition(std::string* disposition) const {
42   if (content_disposition_.empty())
43     return false;
44   *disposition = content_disposition_;
45   return true;
46 }
47 
48 // What was this data requested from a server?
GetRequestTime() const49 base::Time MockFilterContext::GetRequestTime() const {
50   return request_time_;
51 }
52 
IsCachedContent() const53 bool MockFilterContext::IsCachedContent() const { return is_cached_content_; }
54 
IsDownload() const55 bool MockFilterContext::IsDownload() const { return is_download_; }
56 
SdchResponseExpected() const57 bool MockFilterContext::SdchResponseExpected() const {
58   return is_sdch_response_;
59 }
60 
GetByteReadCount() const61 int64 MockFilterContext::GetByteReadCount() const { return 0; }
62 
GetResponseCode() const63 int MockFilterContext::GetResponseCode() const { return response_code_; }
64 
GetURLRequestContext() const65 const URLRequestContext* MockFilterContext::GetURLRequestContext() const {
66   return context_.get();
67 }
68 
69 }  // namespace net
70