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

Unified Diff: net/filter/sdch_policy_delegate.h

Issue 1662763002: [ON HOLD] Implement pull-based design for content decoding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
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..621d439ebba64aee3a0be0e56d3fc4834ceccc25
--- /dev/null
+++ b/net/filter/sdch_policy_delegate.h
@@ -0,0 +1,83 @@
+// 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 "base/supports_user_data.h"
+#include "net/base/sdch_manager.h"
+#include "net/filter/sdch_stream_source_delegate.h"
+#include "net/log/net_log.h"
+#include "url/gurl.h"
+
+namespace net {
+
+class SdchStreamSource;
+
+// This class ascribes to the SdchStreamSourceDelegate interface to implement
+// 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 |SdchStreamSourceDelegate| documentation for more details.
+class SdchPolicyDelegate : public SdchStreamSourceDelegate {
+ 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 base::Time GetRequestTime() 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 void RecordPacketStats(StatisticSelector statistic) const = 0;
+ virtual const BoundNetLog& GetNetLog() const = 0;
+ };
+
+ // We need: MIME type, URL, GetByteReadCount, IsCachedContent,
+ // RecordPacketStats, GetResponseCode, SdchDictionariesAdvertised, netlog
+ SdchPolicyDelegate(scoped_ptr<Context> context);
+
+ ~SdchPolicyDelegate() override;
+
+ // SdchStreamSourceDelegate overrides.
+ bool HandleDictionaryError(SdchStreamSource* source) override;
+ bool HandleDecodingError(SdchStreamSource* source) override;
+ bool GetDictionary(const std::string& server_id,
+ const std::string** text) override;
+ void NotifyStreamDone() 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(SdchStreamSource* 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 LogSdchDictionaryError();
+ void LogSdchDecodingError();
+
+ bool dictionary_requested_;
+ scoped_ptr<Context> context_;
+
+ bool did_meta_refresh_;
+ bool did_stop_decoding_;
+ bool did_fail_request_;
+
+ scoped_ptr<SdchManager::DictionarySet> unexpected_dictionary_set_;
+};
+
+} // namespace net
+
+#endif // !NET_FILTER_SDCH_POLICY_DELEGATE_H

Powered by Google App Engine
This is Rietveld 408576698