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

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

Issue 711753003: Pin dictionaries from being deleted while request is outstanding. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync'd up to p303887 Created 6 years, 1 month 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
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 "base/memory/scoped_ptr.h"
11 #include "net/base/sdch_manager.h"
11 #include "net/filter/filter.h" 12 #include "net/filter/filter.h"
12 #include "url/gurl.h" 13 #include "url/gurl.h"
13 14
14 namespace net { 15 namespace net {
15 16
16 class URLRequestContext; 17 class URLRequestContext;
17 18
18 class MockFilterContext : public FilterContext { 19 class MockFilterContext : public FilterContext {
19 public: 20 public:
20 MockFilterContext(); 21 MockFilterContext();
21 ~MockFilterContext() override; 22 ~MockFilterContext() override;
22 23
23 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } 24 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; }
24 void SetURL(const GURL& gurl) { gurl_ = gurl; } 25 void SetURL(const GURL& gurl) { gurl_ = gurl; }
25 void SetContentDisposition(const std::string& disposition) { 26 void SetContentDisposition(const std::string& disposition) {
26 content_disposition_ = disposition; 27 content_disposition_ = disposition;
27 } 28 }
28 void SetRequestTime(const base::Time time) { request_time_ = time; } 29 void SetRequestTime(const base::Time time) { request_time_ = time; }
29 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } 30 void SetCached(bool is_cached) { is_cached_content_ = is_cached; }
30 void SetDownload(bool is_download) { is_download_ = is_download; } 31 void SetDownload(bool is_download) { is_download_ = is_download; }
31 void SetResponseCode(int response_code) { response_code_ = response_code; } 32 void SetResponseCode(int response_code) { response_code_ = response_code; }
32 void SetSdchResponse(bool is_sdch_response) { 33 void SetSdchResponse(scoped_ptr<SdchManager::DictionarySet> handle) {
33 is_sdch_response_ = is_sdch_response; 34 dictionaries_handle_ = handle.Pass();
34 } 35 }
35 URLRequestContext* GetModifiableURLRequestContext() const { 36 URLRequestContext* GetModifiableURLRequestContext() const {
36 return context_.get(); 37 return context_.get();
37 } 38 }
38 39
39 // After a URLRequest's destructor is called, some interfaces may become 40 // After a URLRequest's destructor is called, some interfaces may become
40 // unstable. This method is used to signal that state, so we can tag use 41 // unstable. This method is used to signal that state, so we can tag use
41 // of those interfaces as coding errors. 42 // of those interfaces as coding errors.
42 void NukeUnstableInterfaces(); 43 void NukeUnstableInterfaces();
43 44
44 bool GetMimeType(std::string* mime_type) const override; 45 bool GetMimeType(std::string* mime_type) const override;
45 46
46 // What URL was used to access this data? 47 // What URL was used to access this data?
47 // Return false if gurl is not present. 48 // Return false if gurl is not present.
48 bool GetURL(GURL* gurl) const override; 49 bool GetURL(GURL* gurl) const override;
49 50
50 // What Content-Disposition did the server supply for this data? 51 // What Content-Disposition did the server supply for this data?
51 // Return false if Content-Disposition was not present. 52 // Return false if Content-Disposition was not present.
52 bool GetContentDisposition(std::string* disposition) const override; 53 bool GetContentDisposition(std::string* disposition) const override;
53 54
54 // What was this data requested from a server? 55 // What was this data requested from a server?
55 base::Time GetRequestTime() const override; 56 base::Time GetRequestTime() const override;
56 57
57 // Is data supplied from cache, or fresh across the net? 58 // Is data supplied from cache, or fresh across the net?
58 bool IsCachedContent() const override; 59 bool IsCachedContent() const override;
59 60
60 // Is this a download? 61 // Is this a download?
61 bool IsDownload() const override; 62 bool IsDownload() const override;
62 63
63 // Was this data flagged as a response to a request with an SDCH dictionary? 64 // Handle to dictionaries advertised.
64 bool SdchResponseExpected() const override; 65 SdchManager::DictionarySet* SdchDictionariesAdvertised() const override;
65 66
66 // How many bytes were fed to filter(s) so far? 67 // How many bytes were fed to filter(s) so far?
67 int64 GetByteReadCount() const override; 68 int64 GetByteReadCount() const override;
68 69
69 int GetResponseCode() const override; 70 int GetResponseCode() const override;
70 71
71 // The URLRequestContext associated with the request. 72 // The URLRequestContext associated with the request.
72 const URLRequestContext* GetURLRequestContext() const override; 73 const URLRequestContext* GetURLRequestContext() const override;
73 74
74 void RecordPacketStats(StatisticSelector statistic) const override {} 75 void RecordPacketStats(StatisticSelector statistic) const override {}
75 76
76 private: 77 private:
77 int buffer_size_; 78 int buffer_size_;
78 std::string mime_type_; 79 std::string mime_type_;
79 std::string content_disposition_; 80 std::string content_disposition_;
80 GURL gurl_; 81 GURL gurl_;
81 base::Time request_time_; 82 base::Time request_time_;
82 bool is_cached_content_; 83 bool is_cached_content_;
83 bool is_download_; 84 bool is_download_;
84 bool is_sdch_response_; 85 scoped_ptr<SdchManager::DictionarySet> dictionaries_handle_;
85 bool ok_to_call_get_url_; 86 bool ok_to_call_get_url_;
86 int response_code_; 87 int response_code_;
87 scoped_ptr<URLRequestContext> context_; 88 scoped_ptr<URLRequestContext> context_;
88 89
89 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); 90 DISALLOW_COPY_AND_ASSIGN(MockFilterContext);
90 }; 91 };
91 92
92 } // namespace net 93 } // namespace net
93 94
94 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_ 95 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698