OLD | NEW |
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 <stdint.h> | 8 #include <stdint.h> |
| 9 |
| 10 #include <memory> |
9 #include <string> | 11 #include <string> |
10 #include <utility> | 12 #include <utility> |
11 | 13 |
12 #include "base/macros.h" | 14 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "net/base/sdch_manager.h" | 15 #include "net/base/sdch_manager.h" |
15 #include "net/filter/filter.h" | 16 #include "net/filter/filter.h" |
16 #include "net/log/net_log.h" | 17 #include "net/log/net_log.h" |
17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
18 | 19 |
19 namespace net { | 20 namespace net { |
20 | 21 |
21 class URLRequestContext; | 22 class URLRequestContext; |
22 | 23 |
23 class MockFilterContext : public FilterContext { | 24 class MockFilterContext : public FilterContext { |
24 public: | 25 public: |
25 MockFilterContext(); | 26 MockFilterContext(); |
26 ~MockFilterContext() override; | 27 ~MockFilterContext() override; |
27 | 28 |
28 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } | 29 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } |
29 void SetURL(const GURL& gurl) { gurl_ = gurl; } | 30 void SetURL(const GURL& gurl) { gurl_ = gurl; } |
30 void SetRequestTime(const base::Time time) { request_time_ = time; } | 31 void SetRequestTime(const base::Time time) { request_time_ = time; } |
31 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } | 32 void SetCached(bool is_cached) { is_cached_content_ = is_cached; } |
32 void SetResponseCode(int response_code) { response_code_ = response_code; } | 33 void SetResponseCode(int response_code) { response_code_ = response_code; } |
33 void SetSdchResponse(scoped_ptr<SdchManager::DictionarySet> handle) { | 34 void SetSdchResponse(std::unique_ptr<SdchManager::DictionarySet> handle) { |
34 dictionaries_handle_ = std::move(handle); | 35 dictionaries_handle_ = std::move(handle); |
35 } | 36 } |
36 URLRequestContext* GetModifiableURLRequestContext() const { | 37 URLRequestContext* GetModifiableURLRequestContext() const { |
37 return context_.get(); | 38 return context_.get(); |
38 } | 39 } |
39 | 40 |
40 // After a URLRequest's destructor is called, some interfaces may become | 41 // After a URLRequest's destructor is called, some interfaces may become |
41 // unstable. This method is used to signal that state, so we can tag use | 42 // unstable. This method is used to signal that state, so we can tag use |
42 // of those interfaces as coding errors. | 43 // of those interfaces as coding errors. |
43 void NukeUnstableInterfaces(); | 44 void NukeUnstableInterfaces(); |
(...skipping 23 matching lines...) Expand all Loading... |
67 | 68 |
68 void RecordPacketStats(StatisticSelector statistic) const override {} | 69 void RecordPacketStats(StatisticSelector statistic) const override {} |
69 | 70 |
70 const BoundNetLog& GetNetLog() const override; | 71 const BoundNetLog& GetNetLog() const override; |
71 | 72 |
72 private: | 73 private: |
73 std::string mime_type_; | 74 std::string mime_type_; |
74 GURL gurl_; | 75 GURL gurl_; |
75 base::Time request_time_; | 76 base::Time request_time_; |
76 bool is_cached_content_; | 77 bool is_cached_content_; |
77 scoped_ptr<SdchManager::DictionarySet> dictionaries_handle_; | 78 std::unique_ptr<SdchManager::DictionarySet> dictionaries_handle_; |
78 bool ok_to_call_get_url_; | 79 bool ok_to_call_get_url_; |
79 int response_code_; | 80 int response_code_; |
80 scoped_ptr<URLRequestContext> context_; | 81 std::unique_ptr<URLRequestContext> context_; |
81 BoundNetLog net_log_; | 82 BoundNetLog net_log_; |
82 | 83 |
83 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); | 84 DISALLOW_COPY_AND_ASSIGN(MockFilterContext); |
84 }; | 85 }; |
85 | 86 |
86 } // namespace net | 87 } // namespace net |
87 | 88 |
88 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_ | 89 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_ |
OLD | NEW |