OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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_SDCH_POLICY_DELEGATE_H_ | |
6 #define NET_FILTER_SDCH_POLICY_DELEGATE_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/macros.h" | |
11 #include "base/supports_user_data.h" | |
12 #include "net/base/net_export.h" | |
13 #include "net/base/sdch_manager.h" | |
14 #include "net/filter/sdch_source_stream.h" | |
15 #include "net/log/net_log.h" | |
16 #include "url/gurl.h" | |
17 | |
18 namespace net { | |
19 | |
20 class SdchSourceStream; | |
21 | |
22 // This class ascribes to the SdchSourceStream::Delegate interface to implement | |
Randy Smith (Not in Mondays)
2016/09/27 20:09:13
nit, suggestion "ascribes to" -> "implements" (thi
xunjieli
2016/09/30 15:32:17
Done.
| |
23 // the SDCH error-handling and stats-gathering policy. The Context object | |
24 // supplies details about the request needed for this object to make | |
25 // error-handling decisions. See the SdchSourceStream::Delegate documentation | |
26 // for more details. | |
27 class NET_EXPORT_PRIVATE SdchPolicyDelegate | |
28 : public SdchSourceStream::Delegate { | |
29 public: | |
30 class Context { | |
31 public: | |
32 enum StatisticSelector { | |
33 SDCH_DECODE, | |
34 SDCH_PASSTHROUGH, | |
35 SDCH_EXPERIMENT_DECODE, | |
36 SDCH_EXPERIMENT_HOLDBACK, | |
37 }; | |
38 | |
39 virtual ~Context() {} | |
40 virtual bool GetMimeType(std::string* mime_type) const = 0; | |
41 virtual bool GetURL(GURL* url) const = 0; | |
42 virtual bool IsCachedContent() const = 0; | |
43 virtual SdchManager* GetSdchManager() const = 0; | |
44 virtual SdchManager::DictionarySet* SdchDictionariesAdvertised() const = 0; | |
45 // virtual int64_t GetByteReadCount() const = 0; | |
46 virtual int GetResponseCode() const = 0; | |
47 virtual const NetLogWithSource& GetNetLog() const = 0; | |
48 }; | |
49 | |
50 SdchPolicyDelegate(std::unique_ptr<Context> context); | |
Randy Smith (Not in Mondays)
2016/09/27 20:09:12
I'd really like to explore the possibility of gett
xunjieli
2016/09/30 15:32:17
I don't like the extra indirection either. However
Randy Smith (Not in Mondays)
2016/10/04 20:06:28
That's fine; thanks.
| |
51 | |
52 ~SdchPolicyDelegate() override; | |
53 | |
54 // SdchSourceStream::Delegate implementation. | |
55 bool OnDictionaryError(SdchSourceStream* source) override; | |
56 bool OnDecodingError(SdchSourceStream* source) override; | |
57 bool OnGetDictionary(const std::string& server_id, | |
58 const std::string** text) override; | |
59 | |
60 private: | |
61 // Issues a meta-refresh if the context's MIME type supports it, and returns | |
62 // whether a refresh was issued. As a side-effect, blacklists the context's | |
63 // domain either temporarily or permanently. | |
64 bool IssueMetaRefreshIfPossible(SdchSourceStream* source); | |
65 | |
66 // Logs an SDCH failure. This logs events in UMA and the net log in | |
67 // |context_|, but has no side-effects on this class or the stream. | |
68 void LogSdchProblem(SdchProblemCode problem); | |
69 | |
70 // Whether OnGetDictionary is invoked. | |
71 bool dictionary_requested_; | |
Randy Smith (Not in Mondays)
2016/09/27 20:09:13
Suggestion: As you know, I'm a bit allergic to the
xunjieli
2016/09/30 15:32:17
Done.
| |
72 | |
73 std::unique_ptr<Context> context_; | |
74 // If the response was encoded with a dictionary different than those | |
75 // advertised (e.g. a cached response using an old dictionary), this | |
76 // variable preserves that dictionary from deletion during decoding. | |
77 std::unique_ptr<SdchManager::DictionarySet> unexpected_dictionary_set_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(SdchPolicyDelegate); | |
80 }; | |
81 | |
82 } // namespace net | |
83 | |
84 #endif // NET_FILTER_SDCH_POLICY_DELEGATE_H_ | |
OLD | NEW |