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

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: Address comments Created 4 years, 8 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
7
8 #include <memory>
9
10 #include "base/supports_user_data.h"
11 #include "net/base/sdch_manager.h"
12 #include "net/filter/sdch_stream_source_delegate.h"
13 #include "net/log/net_log.h"
14 #include "url/gurl.h"
15
16 namespace net {
17
18 class SdchStreamSource;
19
20 // This class ascribes to the SdchStreamSourceDelegate interface to implement
21 // the SDCH error-handling and stats-gathering policy. The Context object
22 // supplies details about the request needed for this object to make
23 // error-handling decisions. See the SdchStreamSourceDelegate documentation for
24 // more details.
25 class SdchPolicyDelegate : public SdchStreamSourceDelegate {
26 public:
27 class Context {
28 public:
29 enum StatisticSelector {
30 SDCH_DECODE,
31 SDCH_PASSTHROUGH,
32 SDCH_EXPERIMENT_DECODE,
33 SDCH_EXPERIMENT_HOLDBACK,
34 };
35
36 virtual ~Context() {}
37 virtual bool GetMimeType(std::string* mime_type) const = 0;
38 virtual bool GetURL(GURL* url) const = 0;
39 virtual base::Time GetRequestTime() const = 0;
40 virtual bool IsCachedContent() const = 0;
41 virtual SdchManager* GetSdchManager() const = 0;
42 virtual SdchManager::DictionarySet* SdchDictionariesAdvertised() const = 0;
43 virtual int64_t GetByteReadCount() const = 0;
44 virtual int GetResponseCode() const = 0;
45 virtual void RecordPacketStats(StatisticSelector statistic) const = 0;
46 virtual const BoundNetLog& GetNetLog() const = 0;
47 };
48
49 // We need: MIME type, URL, GetByteReadCount, IsCachedContent,
50 // RecordPacketStats, GetResponseCode, SdchDictionariesAdvertised, netlog
51 SdchPolicyDelegate(std::unique_ptr<Context> context);
52
53 ~SdchPolicyDelegate() override;
54
55 // SdchStreamSourceDelegate overrides.
56 bool HandleDictionaryError(SdchStreamSource* source) override;
57 bool HandleDecodingError(SdchStreamSource* source) override;
58 bool GetDictionary(const std::string& server_id,
59 const std::string** text) override;
60 void NotifyStreamDone() override;
61
62 private:
63 // Issues a meta-refresh if the context's MIME type supports it, and returns
64 // whether a refresh was issued. As a side-effect, blacklists the context's
65 // domain either temporarily or permanently.
66 bool IssueMetaRefreshIfPossible(SdchStreamSource* source);
67
68 // Logs an SDCH failure. This logs events in UMA and the net log in
69 // |context_|, but has no side-effects on this class or the stream.
70 void LogSdchDictionaryError();
71 void LogSdchDecodingError();
72
73 bool dictionary_requested_;
74 std::unique_ptr<Context> context_;
75
76 bool did_meta_refresh_;
77 bool did_stop_decoding_;
78 bool did_fail_request_;
79
80 std::unique_ptr<SdchManager::DictionarySet> unexpected_dictionary_set_;
81 };
82
83 } // namespace net
84
85 #endif // !NET_FILTER_SDCH_POLICY_DELEGATE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698