[Extensions Toolbar] Move tab-specific logic and increase test robustness
[chromium-blink-merge.git] / net / filter / mock_filter_context.h
blob776a2377cca17e9321e5a357ee9987558fe7be00
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.
5 #ifndef NET_FILTER_MOCK_FILTER_CONTEXT_H_
6 #define NET_FILTER_MOCK_FILTER_CONTEXT_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "net/base/net_log.h"
12 #include "net/base/sdch_manager.h"
13 #include "net/filter/filter.h"
14 #include "url/gurl.h"
16 namespace net {
18 class URLRequestContext;
20 class MockFilterContext : public FilterContext {
21 public:
22 MockFilterContext();
23 ~MockFilterContext() override;
25 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; }
26 void SetURL(const GURL& gurl) { gurl_ = gurl; }
27 void SetContentDisposition(const std::string& disposition) {
28 content_disposition_ = disposition;
30 void SetRequestTime(const base::Time time) { request_time_ = time; }
31 void SetCached(bool is_cached) { is_cached_content_ = is_cached; }
32 void SetDownload(bool is_download) { is_download_ = is_download; }
33 void SetResponseCode(int response_code) { response_code_ = response_code; }
34 void SetSdchResponse(scoped_ptr<SdchManager::DictionarySet> handle) {
35 dictionaries_handle_ = handle.Pass();
37 URLRequestContext* GetModifiableURLRequestContext() const {
38 return context_.get();
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();
46 bool GetMimeType(std::string* mime_type) const override;
48 // What URL was used to access this data?
49 // Return false if gurl is not present.
50 bool GetURL(GURL* gurl) const override;
52 // What Content-Disposition did the server supply for this data?
53 // Return false if Content-Disposition was not present.
54 bool GetContentDisposition(std::string* disposition) const override;
56 // What was this data requested from a server?
57 base::Time GetRequestTime() const override;
59 // Is data supplied from cache, or fresh across the net?
60 bool IsCachedContent() const override;
62 // Is this a download?
63 bool IsDownload() const override;
65 // Handle to dictionaries advertised.
66 SdchManager::DictionarySet* SdchDictionariesAdvertised() const override;
68 // How many bytes were fed to filter(s) so far?
69 int64 GetByteReadCount() const override;
71 int GetResponseCode() const override;
73 // The URLRequestContext associated with the request.
74 const URLRequestContext* GetURLRequestContext() const override;
76 void RecordPacketStats(StatisticSelector statistic) const override {}
78 const BoundNetLog& GetNetLog() const override;
80 private:
81 int buffer_size_;
82 std::string mime_type_;
83 std::string content_disposition_;
84 GURL gurl_;
85 base::Time request_time_;
86 bool is_cached_content_;
87 bool is_download_;
88 scoped_ptr<SdchManager::DictionarySet> dictionaries_handle_;
89 bool ok_to_call_get_url_;
90 int response_code_;
91 scoped_ptr<URLRequestContext> context_;
92 BoundNetLog net_log_;
94 DISALLOW_COPY_AND_ASSIGN(MockFilterContext);
97 } // namespace net
99 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_