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

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

Issue 2368433002: Add net::SdchSourceStream and net::SdchPolicyDelegate (Closed)
Patch Set: Rebased to fix compile error Created 4 years, 2 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
« no previous file with comments | « no previous file | net/filter/sdch_policy_delegate.cc » ('j') | net/filter/sdch_policy_delegate.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <string>
10
11 #include "base/macros.h"
12 #include "base/supports_user_data.h"
13 #include "net/base/net_export.h"
14 #include "net/base/sdch_manager.h"
15 #include "net/filter/sdch_source_stream.h"
16 #include "net/log/net_log.h"
17 #include "net/log/net_log_with_source.h"
18 #include "url/gurl.h"
19
20 namespace net {
21
22 class SdchSourceStream;
23
24 // This class implements the SdchSourceStream::Delegate interface to perform
25 // the SDCH error handling and stats gathering. The Context object supplies
26 // details about the request needed for this object to make error-handling
27 // decisions. See the SdchSourceStream::Delegate documentation for more details.
28 class NET_EXPORT_PRIVATE SdchPolicyDelegate
29 : public SdchSourceStream::Delegate {
30 public:
31 class Context {
32 public:
33 enum StatisticSelector {
34 SDCH_DECODE,
35 SDCH_PASSTHROUGH,
36 SDCH_EXPERIMENT_DECODE,
37 SDCH_EXPERIMENT_HOLDBACK,
38 };
39
40 virtual ~Context() {}
41 virtual bool GetMimeType(std::string* mime_type) const = 0;
42 virtual bool GetURL(GURL* url) const = 0;
43 virtual bool IsCachedContent() const = 0;
44 virtual SdchManager* GetSdchManager() const = 0;
45 virtual SdchManager::DictionarySet* SdchDictionariesAdvertised() const = 0;
46 virtual int GetResponseCode() const = 0;
47 virtual const NetLogWithSource& GetNetLog() const = 0;
48 };
49
50 SdchPolicyDelegate(std::unique_ptr<Context> context);
51
52 ~SdchPolicyDelegate() override;
53
54 // SdchSourceStream::Delegate implementation.
55 ErrorRecovery OnDictionaryIdError(std::string* replace_output) override;
56 ErrorRecovery OnGetDictionaryError(std::string* replace_output) override;
57 ErrorRecovery OnDecodingError(std::string* replace_output) override;
58 bool OnGetDictionary(const std::string& server_id,
59 const std::string** text) override;
60
61 private:
62 // Issues a meta-refresh if the context's MIME type supports it, and returns
63 // whether a refresh was issued. As a side-effect, blacklists the context's
64 // domain either temporarily or permanently.
65 ErrorRecovery IssueMetaRefreshIfPossible(std::string* replace_output);
66
67 // Logs an SDCH failure. This logs events in UMA and the net log in
68 // |context_|, but has no side-effects on this class or the stream.
69 void LogSdchProblem(SdchProblemCode problem);
70
71 std::unique_ptr<Context> context_;
72 // If the response was encoded with a dictionary different than those
73 // advertised (e.g. a cached response using an old dictionary), this
74 // variable preserves that dictionary from deletion during decoding.
75 std::unique_ptr<SdchManager::DictionarySet> unexpected_dictionary_set_;
76
77 DISALLOW_COPY_AND_ASSIGN(SdchPolicyDelegate);
78 };
79
80 } // namespace net
81
82 #endif // NET_FILTER_SDCH_POLICY_DELEGATE_H_
OLDNEW
« no previous file with comments | « no previous file | net/filter/sdch_policy_delegate.cc » ('j') | net/filter/sdch_policy_delegate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698