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

Unified Diff: net/filter/sdch_policy_delegate.h

Issue 2368433002: Add net::SdchSourceStream and net::SdchPolicyDelegate (Closed)
Patch Set: tidy up tests Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/filter/sdch_policy_delegate.cc » ('j') | net/filter/sdch_policy_delegate.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/filter/sdch_policy_delegate.h
diff --git a/net/filter/sdch_policy_delegate.h b/net/filter/sdch_policy_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..ade2db8db63a337da13f1290d36512400c1e70eb
--- /dev/null
+++ b/net/filter/sdch_policy_delegate.h
@@ -0,0 +1,84 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_FILTER_SDCH_POLICY_DELEGATE_H_
+#define NET_FILTER_SDCH_POLICY_DELEGATE_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "base/supports_user_data.h"
+#include "net/base/net_export.h"
+#include "net/base/sdch_manager.h"
+#include "net/filter/sdch_source_stream.h"
+#include "net/log/net_log.h"
+#include "url/gurl.h"
+
+namespace net {
+
+class SdchSourceStream;
+
+// This class ascribes to the SdchSourceStream::Delegate interface to implement
Randy Smith (Not in Mondays) 2016/09/27 20:09:13 nit, suggestion "ascribes to" -> "implements" (thi
xunjieli 2016/09/30 15:32:17 Done.
+// the SDCH error-handling and stats-gathering policy. The Context object
+// supplies details about the request needed for this object to make
+// error-handling decisions. See the SdchSourceStream::Delegate documentation
+// for more details.
+class NET_EXPORT_PRIVATE SdchPolicyDelegate
+ : public SdchSourceStream::Delegate {
+ public:
+ class Context {
+ public:
+ enum StatisticSelector {
+ SDCH_DECODE,
+ SDCH_PASSTHROUGH,
+ SDCH_EXPERIMENT_DECODE,
+ SDCH_EXPERIMENT_HOLDBACK,
+ };
+
+ virtual ~Context() {}
+ virtual bool GetMimeType(std::string* mime_type) const = 0;
+ virtual bool GetURL(GURL* url) const = 0;
+ virtual bool IsCachedContent() const = 0;
+ virtual SdchManager* GetSdchManager() const = 0;
+ virtual SdchManager::DictionarySet* SdchDictionariesAdvertised() const = 0;
+ // virtual int64_t GetByteReadCount() const = 0;
+ virtual int GetResponseCode() const = 0;
+ virtual const NetLogWithSource& GetNetLog() const = 0;
+ };
+
+ SdchPolicyDelegate(std::unique_ptr<Context> context);
Randy Smith (Not in Mondays) 2016/09/27 20:09:12 I'd really like to explore the possibility of gett
xunjieli 2016/09/30 15:32:17 I don't like the extra indirection either. However
Randy Smith (Not in Mondays) 2016/10/04 20:06:28 That's fine; thanks.
+
+ ~SdchPolicyDelegate() override;
+
+ // SdchSourceStream::Delegate implementation.
+ bool OnDictionaryError(SdchSourceStream* source) override;
+ bool OnDecodingError(SdchSourceStream* source) override;
+ bool OnGetDictionary(const std::string& server_id,
+ const std::string** text) override;
+
+ private:
+ // Issues a meta-refresh if the context's MIME type supports it, and returns
+ // whether a refresh was issued. As a side-effect, blacklists the context's
+ // domain either temporarily or permanently.
+ bool IssueMetaRefreshIfPossible(SdchSourceStream* source);
+
+ // Logs an SDCH failure. This logs events in UMA and the net log in
+ // |context_|, but has no side-effects on this class or the stream.
+ void LogSdchProblem(SdchProblemCode problem);
+
+ // Whether OnGetDictionary is invoked.
+ bool dictionary_requested_;
Randy Smith (Not in Mondays) 2016/09/27 20:09:13 Suggestion: As you know, I'm a bit allergic to the
xunjieli 2016/09/30 15:32:17 Done.
+
+ std::unique_ptr<Context> context_;
+ // If the response was encoded with a dictionary different than those
+ // advertised (e.g. a cached response using an old dictionary), this
+ // variable preserves that dictionary from deletion during decoding.
+ std::unique_ptr<SdchManager::DictionarySet> unexpected_dictionary_set_;
+
+ DISALLOW_COPY_AND_ASSIGN(SdchPolicyDelegate);
+};
+
+} // namespace net
+
+#endif // NET_FILTER_SDCH_POLICY_DELEGATE_H_
« 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