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

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: 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 "net/filter/filter.h" 10 #include "net/filter/filter.h"
11 #include "url/gurl.h" 11 #include "url/gurl.h"
12 12
13 namespace net { 13 namespace net {
14 14
15 class URLRequestContext;
16
15 class MockFilterContext : public FilterContext { 17 class MockFilterContext : public FilterContext {
16 public: 18 public:
17 MockFilterContext(); 19 MockFilterContext();
18 virtual ~MockFilterContext(); 20 virtual ~MockFilterContext();
19 21
20 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } 22 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; }
21 void SetURL(const GURL& gurl) { gurl_ = gurl; } 23 void SetURL(const GURL& gurl) { gurl_ = gurl; }
22 void SetContentDisposition(const std::string& disposition) { 24 void SetContentDisposition(const std::string& disposition) {
23 content_disposition_ = disposition; 25 content_disposition_ = disposition;
24 } 26 }
25 void SetRequestTime(const base::Time time) { request_time_ = time; } 27 void SetRequestTime(const base::Time time) { request_time_ = time; }
26 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } 28 void SetCached(bool is_cached) { is_cached_content_ = is_cached; }
27 void SetDownload(bool is_download) { is_download_ = is_download; } 29 void SetDownload(bool is_download) { is_download_ = is_download; }
28 void SetResponseCode(int response_code) { response_code_ = response_code; } 30 void SetResponseCode(int response_code) { response_code_ = response_code; }
29 void SetSdchResponse(bool is_sdch_response) { 31 void SetSdchResponse(bool is_sdch_response) {
30 is_sdch_response_ = is_sdch_response; 32 is_sdch_response_ = is_sdch_response;
31 } 33 }
34 void SetURLRequestContext(URLRequestContext* context) {
35 context_ = context;
36 }
32 37
33 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; 38 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE;
34 39
35 // What URL was used to access this data? 40 // What URL was used to access this data?
36 // Return false if gurl is not present. 41 // Return false if gurl is not present.
37 virtual bool GetURL(GURL* gurl) const OVERRIDE; 42 virtual bool GetURL(GURL* gurl) const OVERRIDE;
38 43
39 // What Content-Disposition did the server supply for this data? 44 // What Content-Disposition did the server supply for this data?
40 // Return false if Content-Disposition was not present. 45 // Return false if Content-Disposition was not present.
41 virtual bool GetContentDisposition(std::string* disposition) const OVERRIDE; 46 virtual bool GetContentDisposition(std::string* disposition) const OVERRIDE;
42 47
43 // What was this data requested from a server? 48 // What was this data requested from a server?
44 virtual base::Time GetRequestTime() const OVERRIDE; 49 virtual base::Time GetRequestTime() const OVERRIDE;
45 50
46 // Is data supplied from cache, or fresh across the net? 51 // Is data supplied from cache, or fresh across the net?
47 virtual bool IsCachedContent() const OVERRIDE; 52 virtual bool IsCachedContent() const OVERRIDE;
48 53
49 // Is this a download? 54 // Is this a download?
50 virtual bool IsDownload() const OVERRIDE; 55 virtual bool IsDownload() const OVERRIDE;
51 56
52 // Was this data flagged as a response to a request with an SDCH dictionary? 57 // Was this data flagged as a response to a request with an SDCH dictionary?
53 virtual bool IsSdchResponse() const OVERRIDE; 58 virtual bool IsSdchResponse() const OVERRIDE;
54 59
55 // How many bytes were fed to filter(s) so far? 60 // How many bytes were fed to filter(s) so far?
56 virtual int64 GetByteReadCount() const OVERRIDE; 61 virtual int64 GetByteReadCount() const OVERRIDE;
57 62
58 virtual int GetResponseCode() const OVERRIDE; 63 virtual int GetResponseCode() const OVERRIDE;
59 64
65 // The URLRequestContext associated with the request.
66 virtual const URLRequestContext* GetURLRequestContext() const OVERRIDE;
67
60 virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE {} 68 virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE {}
61 69
62 private: 70 private:
63 int buffer_size_; 71 int buffer_size_;
64 std::string mime_type_; 72 std::string mime_type_;
65 std::string content_disposition_; 73 std::string content_disposition_;
66 GURL gurl_; 74 GURL gurl_;
67 base::Time request_time_; 75 base::Time request_time_;
68 bool is_cached_content_; 76 bool is_cached_content_;
69 bool is_download_; 77 bool is_download_;
70 bool is_sdch_response_; 78 bool is_sdch_response_;
71 int response_code_; 79 int response_code_;
80 URLRequestContext* context_;
72 81
73 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); 82 DISALLOW_COPY_AND_ASSIGN(MockFilterContext);
74 }; 83 };
75 84
76 } // namespace net 85 } // namespace net
77 86
78 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_ 87 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698