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

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

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

Powered by Google App Engine
This is Rietveld 408576698