Ensure favicon images are correctly used and downloaded when syncing bookmark apps.
[chromium-blink-merge.git] / net / filter / mock_filter_context.h
blob33d41a6e53ee6880f5b9a82ded51f971c075284f
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/sdch_manager.h"
12 #include "net/filter/filter.h"
13 #include "net/log/net_log.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 SetRequestTime(const base::Time time) { request_time_ = time; }
28 void SetCached(bool is_cached) { is_cached_content_ = is_cached; }
29 void SetResponseCode(int response_code) { response_code_ = response_code; }
30 void SetSdchResponse(scoped_ptr<SdchManager::DictionarySet> handle) {
31 dictionaries_handle_ = handle.Pass();
33 URLRequestContext* GetModifiableURLRequestContext() const {
34 return context_.get();
37 // After a URLRequest's destructor is called, some interfaces may become
38 // unstable. This method is used to signal that state, so we can tag use
39 // of those interfaces as coding errors.
40 void NukeUnstableInterfaces();
42 bool GetMimeType(std::string* mime_type) const override;
44 // What URL was used to access this data?
45 // Return false if gurl is not present.
46 bool GetURL(GURL* gurl) const override;
48 // What was this data requested from a server?
49 base::Time GetRequestTime() const override;
51 // Is data supplied from cache, or fresh across the net?
52 bool IsCachedContent() const override;
54 // Handle to dictionaries advertised.
55 SdchManager::DictionarySet* SdchDictionariesAdvertised() const override;
57 // How many bytes were fed to filter(s) so far?
58 int64 GetByteReadCount() const override;
60 int GetResponseCode() const override;
62 // The URLRequestContext associated with the request.
63 const URLRequestContext* GetURLRequestContext() const override;
65 void RecordPacketStats(StatisticSelector statistic) const override {}
67 const BoundNetLog& GetNetLog() const override;
69 private:
70 std::string mime_type_;
71 GURL gurl_;
72 base::Time request_time_;
73 bool is_cached_content_;
74 scoped_ptr<SdchManager::DictionarySet> dictionaries_handle_;
75 bool ok_to_call_get_url_;
76 int response_code_;
77 scoped_ptr<URLRequestContext> context_;
78 BoundNetLog net_log_;
80 DISALLOW_COPY_AND_ASSIGN(MockFilterContext);
83 } // namespace net
85 #endif // NET_FILTER_MOCK_FILTER_CONTEXT_H_