Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: net/filter/mock_filter_context.h

Issue 298063006: Make SdchManager per-profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make access to sdch manager in tests go through an accessor." Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "net/filter/filter.h" 11 #include "net/filter/filter.h"
11 #include "url/gurl.h" 12 #include "url/gurl.h"
12 13
13 namespace net { 14 namespace net {
14 15
16 class URLRequestContext;
17
15 class MockFilterContext : public FilterContext { 18 class MockFilterContext : public FilterContext {
16 public: 19 public:
17 MockFilterContext(); 20 MockFilterContext();
18 virtual ~MockFilterContext(); 21 virtual ~MockFilterContext();
19 22
20 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } 23 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; }
21 void SetURL(const GURL& gurl) { gurl_ = gurl; } 24 void SetURL(const GURL& gurl) { gurl_ = gurl; }
22 void SetContentDisposition(const std::string& disposition) { 25 void SetContentDisposition(const std::string& disposition) {
23 content_disposition_ = disposition; 26 content_disposition_ = disposition;
24 } 27 }
25 void SetRequestTime(const base::Time time) { request_time_ = time; } 28 void SetRequestTime(const base::Time time) { request_time_ = time; }
26 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } 29 void SetCached(bool is_cached) { is_cached_content_ = is_cached; }
27 void SetDownload(bool is_download) { is_download_ = is_download; } 30 void SetDownload(bool is_download) { is_download_ = is_download; }
28 void SetResponseCode(int response_code) { response_code_ = response_code; } 31 void SetResponseCode(int response_code) { response_code_ = response_code; }
29 void SetSdchResponse(bool is_sdch_response) { 32 void SetSdchResponse(bool is_sdch_response) {
30 is_sdch_response_ = is_sdch_response; 33 is_sdch_response_ = is_sdch_response;
31 } 34 }
35 URLRequestContext* GetModifiableURLRequestContext() { return context_.get(); }
jar (doing other things) 2014/06/09 23:03:01 nit: nice to use const on such accessors.
Randy Smith (Not in Mondays) 2014/06/10 20:38:41 Actually, the whole point of this accessor is that
jar (doing other things) 2014/06/11 20:04:43 I wasn't asking for the return value to be const,
Randy Smith (Not in Mondays) 2014/06/11 20:43:37 Sorry, another const parsing braino. Done.
32 36
33 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; 37 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE;
34 38
35 // What URL was used to access this data? 39 // What URL was used to access this data?
36 // Return false if gurl is not present. 40 // Return false if gurl is not present.
37 virtual bool GetURL(GURL* gurl) const OVERRIDE; 41 virtual bool GetURL(GURL* gurl) const OVERRIDE;
38 42
39 // What Content-Disposition did the server supply for this data? 43 // What Content-Disposition did the server supply for this data?
40 // Return false if Content-Disposition was not present. 44 // Return false if Content-Disposition was not present.
41 virtual bool GetContentDisposition(std::string* disposition) const OVERRIDE; 45 virtual bool GetContentDisposition(std::string* disposition) const OVERRIDE;
42 46
43 // What was this data requested from a server? 47 // What was this data requested from a server?
44 virtual base::Time GetRequestTime() const OVERRIDE; 48 virtual base::Time GetRequestTime() const OVERRIDE;
45 49
46 // Is data supplied from cache, or fresh across the net? 50 // Is data supplied from cache, or fresh across the net?
47 virtual bool IsCachedContent() const OVERRIDE; 51 virtual bool IsCachedContent() const OVERRIDE;
48 52
49 // Is this a download? 53 // Is this a download?
50 virtual bool IsDownload() const OVERRIDE; 54 virtual bool IsDownload() const OVERRIDE;
51 55
52 // Was this data flagged as a response to a request with an SDCH dictionary? 56 // Was this data flagged as a response to a request with an SDCH dictionary?
53 virtual bool IsSdchResponse() const OVERRIDE; 57 virtual bool IsSdchResponse() const OVERRIDE;
54 58
55 // How many bytes were fed to filter(s) so far? 59 // How many bytes were fed to filter(s) so far?
56 virtual int64 GetByteReadCount() const OVERRIDE; 60 virtual int64 GetByteReadCount() const OVERRIDE;
57 61
58 virtual int GetResponseCode() const OVERRIDE; 62 virtual int GetResponseCode() const OVERRIDE;
59 63
64 // The URLRequestContext associated with the request.
65 virtual const URLRequestContext* GetURLRequestContext() const OVERRIDE;
66
60 virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE {} 67 virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE {}
61 68
62 private: 69 private:
63 int buffer_size_; 70 int buffer_size_;
64 std::string mime_type_; 71 std::string mime_type_;
65 std::string content_disposition_; 72 std::string content_disposition_;
66 GURL gurl_; 73 GURL gurl_;
67 base::Time request_time_; 74 base::Time request_time_;
68 bool is_cached_content_; 75 bool is_cached_content_;
69 bool is_download_; 76 bool is_download_;
70 bool is_sdch_response_; 77 bool is_sdch_response_;
71 int response_code_; 78 int response_code_;
79 scoped_ptr<URLRequestContext> context_;
72 80
73 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); 81 DISALLOW_COPY_AND_ASSIGN(MockFilterContext);
74 }; 82 };
75 83
76 } // namespace net 84 } // namespace net
77 85
78 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_ 86 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698