Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / net / base / mock_filter_context.h
1 // Copyright (c) 2011 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_BASE_MOCK_FILTER_CONTEXT_H_
6 #define NET_BASE_MOCK_FILTER_CONTEXT_H_
7
8 #include <string>
9
10 #include "net/base/filter.h"
11 #include "url/gurl.h"
12
13 namespace net {
14
15 class MockFilterContext : public FilterContext {
16  public:
17   MockFilterContext();
18   virtual ~MockFilterContext();
19
20   void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; }
21   void SetURL(const GURL& gurl) { gurl_ = gurl; }
22   void SetRequestTime(const base::Time time) { request_time_ = time; }
23   void SetCached(bool is_cached) { is_cached_content_ = is_cached; }
24   void SetDownload(bool is_download) { is_download_ = is_download; }
25   void SetResponseCode(int response_code) { response_code_ = response_code; }
26   void SetSdchResponse(bool is_sdch_response) {
27     is_sdch_response_ = is_sdch_response;
28   }
29
30   virtual bool GetMimeType(std::string* mime_type) const OVERRIDE;
31
32   // What URL was used to access this data?
33   // Return false if gurl is not present.
34   virtual bool GetURL(GURL* gurl) const OVERRIDE;
35
36   // What was this data requested from a server?
37   virtual base::Time GetRequestTime() const OVERRIDE;
38
39   // Is data supplied from cache, or fresh across the net?
40   virtual bool IsCachedContent() const OVERRIDE;
41
42   // Is this a download?
43   virtual bool IsDownload() const OVERRIDE;
44
45   // Was this data flagged as a response to a request with an SDCH dictionary?
46   virtual bool IsSdchResponse() const OVERRIDE;
47
48   // How many bytes were fed to filter(s) so far?
49   virtual int64 GetByteReadCount() const OVERRIDE;
50
51   virtual int GetResponseCode() const OVERRIDE;
52
53   virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE {}
54
55  private:
56   int buffer_size_;
57   std::string mime_type_;
58   GURL gurl_;
59   base::Time request_time_;
60   bool is_cached_content_;
61   bool is_download_;
62   bool is_sdch_response_;
63   int response_code_;
64
65   DISALLOW_COPY_AND_ASSIGN(MockFilterContext);
66 };
67
68 }  // namespace net
69
70 #endif  // NET_BASE_MOCK_FILTER_CONTEXT_H_