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

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

Issue 2368433002: Add net::SdchSourceStream and net::SdchPolicyDelegate (Closed)
Patch Set: Fix histograms 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 | « net/filter/filter_source_stream.cc ('k') | net/filter/sdch_policy_delegate.cc » ('j') | no next file with comments »
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 URLRequestHttpJob;
23 class SdchSourceStream;
24
25 // This class implements the SdchSourceStream::Delegate interface to perform
26 // the SDCH error handling and stats gathering. The Context object supplies
27 // details about the request needed for this object to make error-handling
28 // decisions. See the SdchSourceStream::Delegate documentation for more details.
29 class NET_EXPORT_PRIVATE SdchPolicyDelegate
30 : public SdchSourceStream::Delegate {
31 public:
32 enum StatisticSelector {
33 SDCH_DECODE,
34 SDCH_PASSTHROUGH,
35 SDCH_EXPERIMENT_DECODE,
36 SDCH_EXPERIMENT_HOLDBACK,
37 };
38
39 SdchPolicyDelegate(bool possible_pass_through,
40 URLRequestHttpJob* job,
41 std::string mime_type,
42 const GURL& url,
43 bool is_cached_content,
44 SdchManager* sdch_manager,
45 std::unique_ptr<SdchManager::DictionarySet> dictionary_set,
46 int response_code,
47 const NetLogWithSource& net_log);
48
49 ~SdchPolicyDelegate() override;
50
51 // Sdch specific hacks to fix up encoding types.
52 static void FixUpSdchContentEncodings(
53 const NetLogWithSource& net_log,
54 const std::string& mime_type,
55 SdchManager::DictionarySet* dictionary_set,
56 std::vector<SourceStream::SourceType>* types);
57
58 // SdchSourceStream::Delegate implementation.
59 ErrorRecovery OnDictionaryIdError(std::string* replace_output) override;
60 ErrorRecovery OnGetDictionaryError(std::string* replace_output) override;
61 ErrorRecovery OnDecodingError(std::string* replace_output) override;
62 bool OnGetDictionary(const std::string& server_id,
63 const std::string** text) override;
64
65 void OnStreamDestroyed(SdchSourceStream::InputState input_state,
66 bool buffered_output_present,
67 bool decoding_not_finished) override;
68
69 private:
70 // Issues a meta-refresh if the context's MIME type supports it, and returns
71 // whether a ErrorRecovery which should either be NONE (meta-refresh not
72 // issued) or REPLACE_OUTPUT (meta-refresh issued). For response not coming
73 // from the cache, the domain will be blacklisted as a side effect temporarily
74 // (for HTML payloads) or permanently (for non-HTML payloads).
75 ErrorRecovery IssueMetaRefreshIfPossible(std::string* replace_output);
76
77 // Set when the SdchSourceStream is used as a possible pass-through.
78 const bool possible_pass_through_;
79
80 // Fields from URLRequestHttpJob.
81 const URLRequestHttpJob* job_;
82 const std::string mime_type_;
83 const GURL url_;
84 const bool is_cached_content_;
85 SdchManager* sdch_manager_;
86 std::unique_ptr<SdchManager::DictionarySet> dictionary_set_;
87 const int response_code_;
88 const NetLogWithSource net_log_;
89
90 std::string server_id_;
91
92 // If the response was encoded with a dictionary different than those
93 // advertised (e.g. a cached response using an old dictionary), this
94 // variable preserves that dictionary from deletion during decoding.
95 std::unique_ptr<SdchManager::DictionarySet> unexpected_dictionary_set_;
96
97 DISALLOW_COPY_AND_ASSIGN(SdchPolicyDelegate);
98 };
99
100 } // namespace net
101
102 #endif // NET_FILTER_SDCH_POLICY_DELEGATE_H_
OLDNEW
« no previous file with comments | « net/filter/filter_source_stream.cc ('k') | net/filter/sdch_policy_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698