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

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

Issue 2478703004: Remove net::Filter code (Closed)
Patch Set: Mark histograms obsolete instead of delete Created 4 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
(Empty)
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 #ifndef NET_FILTER_MOCK_FILTER_CONTEXT_H_
6 #define NET_FILTER_MOCK_FILTER_CONTEXT_H_
7
8 #include <stdint.h>
9
10 #include <memory>
11 #include <string>
12 #include <utility>
13
14 #include "base/macros.h"
15 #include "net/base/sdch_manager.h"
16 #include "net/filter/filter.h"
17 #include "net/log/net_log_with_source.h"
18 #include "url/gurl.h"
19
20 namespace net {
21
22 class URLRequestContext;
23
24 class MockFilterContext : public FilterContext {
25 public:
26 MockFilterContext();
27 ~MockFilterContext() override;
28
29 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; }
30 void SetURL(const GURL& gurl) { gurl_ = gurl; }
31 void SetRequestTime(const base::Time time) { request_time_ = time; }
32 void SetCached(bool is_cached) { is_cached_content_ = is_cached; }
33 void SetResponseCode(int response_code) { response_code_ = response_code; }
34 void SetSdchResponse(std::unique_ptr<SdchManager::DictionarySet> handle) {
35 dictionaries_handle_ = std::move(handle);
36 }
37 URLRequestContext* GetModifiableURLRequestContext() const {
38 return context_.get();
39 }
40
41 // After a URLRequest's destructor is called, some interfaces may become
42 // unstable. This method is used to signal that state, so we can tag use
43 // of those interfaces as coding errors.
44 void NukeUnstableInterfaces();
45
46 bool GetMimeType(std::string* mime_type) const override;
47
48 // What URL was used to access this data?
49 // Return false if gurl is not present.
50 bool GetURL(GURL* gurl) const override;
51
52 // What was this data requested from a server?
53 base::Time GetRequestTime() const override;
54
55 // Is data supplied from cache, or fresh across the net?
56 bool IsCachedContent() const override;
57
58 // Handle to dictionaries advertised.
59 SdchManager::DictionarySet* SdchDictionariesAdvertised() const override;
60
61 // How many bytes were fed to filter(s) so far?
62 int64_t GetByteReadCount() const override;
63
64 int GetResponseCode() const override;
65
66 // The URLRequestContext associated with the request.
67 const URLRequestContext* GetURLRequestContext() const override;
68
69 void RecordPacketStats(StatisticSelector statistic) const override {}
70
71 const NetLogWithSource& GetNetLog() const override;
72
73 private:
74 std::string mime_type_;
75 GURL gurl_;
76 base::Time request_time_;
77 bool is_cached_content_;
78 std::unique_ptr<SdchManager::DictionarySet> dictionaries_handle_;
79 bool ok_to_call_get_url_;
80 int response_code_;
81 std::unique_ptr<URLRequestContext> context_;
82 NetLogWithSource net_log_;
83
84 DISALLOW_COPY_AND_ASSIGN(MockFilterContext);
85 };
86
87 } // namespace net
88
89 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698