Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: net/filter/sdch_policy_delegate.h

Issue 1662763002: [ON HOLD] Implement pull-based design for content decoding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile on mac Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
mmenke 2016/07/21 18:14:09 +_ (x3)
xunjieli 2016/07/27 20:32:03 Done.
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_stream_source.h"
15 #include "net/log/net_log.h"
16 #include "url/gurl.h"
17
18 namespace net {
19
20 class SdchStreamSource;
21
22 // This class ascribes to the SdchStreamSource::Delegate interface to implement
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 SdchStreamSource::Delegate documentation
26 // for more details.
27 class NET_EXPORT_PRIVATE SdchPolicyDelegate
28 : public SdchStreamSource::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 BoundNetLog& GetNetLog() const = 0;
48 };
49
50 SdchPolicyDelegate(std::unique_ptr<Context> context);
51
52 ~SdchPolicyDelegate() override;
53
54 // SdchStreamSource::Delegate implementation.
55 bool OnDictionaryError(SdchStreamSource* source) override;
56 bool OnDecodingError(SdchStreamSource* 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(SdchStreamSource* 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 bool dictionary_requested_;
71
72 std::unique_ptr<Context> context_;
73 // If the response was encoded with a dictionary different than those
74 // advertised (e.g. a cached response using an old dictionary), this
75 // variable preserves that dictionary from deletion during decoding.
76 std::unique_ptr<SdchManager::DictionarySet> unexpected_dictionary_set_;
77
78 DISALLOW_COPY_AND_ASSIGN(SdchPolicyDelegate);
79 };
80
81 } // namespace net
82
83 #endif // !NET_FILTER_SDCH_POLICY_DELEGATE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698