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

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

Issue 2368433002: Add net::SdchSourceStream and net::SdchPolicyDelegate (Closed)
Patch Set: fix meta refresh 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 "url/gurl.h"
18
19 namespace net {
20
21 class SdchSourceStream;
22
23 // This class implements the SdchSourceStream::Delegate interface to perform
24 // the SDCH error handling and stats gathering. The Context object supplies
25 // details about the request needed for this object to make error-handling
26 // decisions. See the SdchSourceStream::Delegate documentation 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 int GetResponseCode() const = 0;
46 virtual const NetLogWithSource& GetNetLog() const = 0;
47 };
48
49 SdchPolicyDelegate(std::unique_ptr<Context> context);
50
51 ~SdchPolicyDelegate() override;
52
53 // SdchSourceStream::Delegate implementation.
54 ErrorRecover OnDictionaryIdError(SdchSourceStream* source,
55 std::string* replace_output) override;
56 ErrorRecover OnGetDictionaryError(SdchSourceStream* source,
57 std::string* replace_output) override;
58 ErrorRecover OnDecodingError(SdchSourceStream* source,
59 std::string* replace_output) override;
60 bool OnGetDictionary(const std::string& server_id,
61 const std::string** text) override;
62
63 private:
64 // Issues a meta-refresh if the context's MIME type supports it, and returns
65 // whether a refresh was issued. As a side-effect, blacklists the context's
66 // domain either temporarily or permanently.
67 ErrorRecover IssueMetaRefreshIfPossible(SdchSourceStream* source,
68 std::string* replace_output);
69
70 // Logs an SDCH failure. This logs events in UMA and the net log in
71 // |context_|, but has no side-effects on this class or the stream.
72 void LogSdchProblem(SdchProblemCode problem);
73
74 std::unique_ptr<Context> context_;
75 // If the response was encoded with a dictionary different than those
76 // advertised (e.g. a cached response using an old dictionary), this
77 // variable preserves that dictionary from deletion during decoding.
78 std::unique_ptr<SdchManager::DictionarySet> unexpected_dictionary_set_;
79
80 DISALLOW_COPY_AND_ASSIGN(SdchPolicyDelegate);
81 };
82
83 } // namespace net
84
85 #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