| OLD | NEW | 
|---|
| (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 "base/supports_user_data.h" | 
|  | 9 #include "net/base/sdch_manager.h" | 
|  | 10 #include "net/filter/sdch_stream_source_delegate.h" | 
|  | 11 #include "net/log/net_log.h" | 
|  | 12 #include "url/gurl.h" | 
|  | 13 | 
|  | 14 namespace net { | 
|  | 15 | 
|  | 16 class SdchStreamSource; | 
|  | 17 | 
|  | 18 // This class ascribes to the SdchStreamSourceDelegate interface to implement | 
|  | 19 // the SDCH | 
|  | 20 // error-handling and stats-gathering policy. The Context object supplies | 
|  | 21 // details about the request needed for this object to make error-handling | 
|  | 22 // decisions. See the |SdchStreamSourceDelegate| documentation for more details. | 
|  | 23 class SdchPolicyDelegate : public SdchStreamSourceDelegate { | 
|  | 24  public: | 
|  | 25   class Context { | 
|  | 26    public: | 
|  | 27     enum StatisticSelector { | 
|  | 28       SDCH_DECODE, | 
|  | 29       SDCH_PASSTHROUGH, | 
|  | 30       SDCH_EXPERIMENT_DECODE, | 
|  | 31       SDCH_EXPERIMENT_HOLDBACK, | 
|  | 32     }; | 
|  | 33 | 
|  | 34     virtual ~Context() {} | 
|  | 35     virtual bool GetMimeType(std::string* mime_type) const = 0; | 
|  | 36     virtual bool GetURL(GURL* url) const = 0; | 
|  | 37     virtual base::Time GetRequestTime() const = 0; | 
|  | 38     virtual bool IsCachedContent() const = 0; | 
|  | 39     virtual SdchManager* GetSdchManager() const = 0; | 
|  | 40     virtual SdchManager::DictionarySet* SdchDictionariesAdvertised() const = 0; | 
|  | 41     virtual int64_t GetByteReadCount() const = 0; | 
|  | 42     virtual int GetResponseCode() const = 0; | 
|  | 43     virtual void RecordPacketStats(StatisticSelector statistic) const = 0; | 
|  | 44     virtual const BoundNetLog& GetNetLog() const = 0; | 
|  | 45   }; | 
|  | 46 | 
|  | 47   // We need: MIME type, URL, GetByteReadCount, IsCachedContent, | 
|  | 48   // RecordPacketStats, GetResponseCode, SdchDictionariesAdvertised, netlog | 
|  | 49   SdchPolicyDelegate(scoped_ptr<Context> context); | 
|  | 50 | 
|  | 51   ~SdchPolicyDelegate() override; | 
|  | 52 | 
|  | 53   // SdchStreamSourceDelegate overrides. | 
|  | 54   bool HandleDictionaryError(SdchStreamSource* source) override; | 
|  | 55   bool HandleDecodingError(SdchStreamSource* source) override; | 
|  | 56   bool GetDictionary(const std::string& server_id, | 
|  | 57                      const std::string** text) override; | 
|  | 58   void NotifyStreamDone() override; | 
|  | 59 | 
|  | 60  private: | 
|  | 61   // Issues a meta-refresh if the context's MIME type supports it, and returns | 
|  | 62   // whether a refresh was issued. As a side-effect, blacklists the context's | 
|  | 63   // domain either temporarily or permanently. | 
|  | 64   bool IssueMetaRefreshIfPossible(SdchStreamSource* source); | 
|  | 65 | 
|  | 66   // Logs an SDCH failure. This logs events in UMA and the net log in | 
|  | 67   // |context_|, but has no side-effects on this class or the stream. | 
|  | 68   void LogSdchDictionaryError(); | 
|  | 69   void LogSdchDecodingError(); | 
|  | 70 | 
|  | 71   bool dictionary_requested_; | 
|  | 72   scoped_ptr<Context> context_; | 
|  | 73 | 
|  | 74   bool did_meta_refresh_; | 
|  | 75   bool did_stop_decoding_; | 
|  | 76   bool did_fail_request_; | 
|  | 77 | 
|  | 78   scoped_ptr<SdchManager::DictionarySet> unexpected_dictionary_set_; | 
|  | 79 }; | 
|  | 80 | 
|  | 81 }  // namespace net | 
|  | 82 | 
|  | 83 #endif  // !NET_FILTER_SDCH_POLICY_DELEGATE_H | 
| OLD | NEW | 
|---|