Chromium Code Reviews| Index: net/filter/sdch_stream_source_delegate.h |
| diff --git a/net/filter/sdch_stream_source_delegate.h b/net/filter/sdch_stream_source_delegate.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9fbc5e4abc1e345364090e83b9e98964ca935d9b |
| --- /dev/null |
| +++ b/net/filter/sdch_stream_source_delegate.h |
| @@ -0,0 +1,60 @@ |
| +// 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_STREAM_SOURCE_DELEGATE_H_ |
| +#define NET_FILTER_SDCH_STREAM_SOURCE_DELEGATE_H_ |
| + |
| +#include <string> |
| + |
| +namespace net { |
| + |
| +class SdchStreamSource; |
| + |
| +// The SdchStreamSourceDelegate class acts as a delegate for |
| +// SdchStreamSource and is responsible for error recovery and stats gathering. |
| +// See the methods below for descriptions of which errors the delegate is |
| +// expected to handle and what it can do to repair them. |
| +class SdchStreamSourceDelegate { |
|
Randy Smith (Not in Mondays)
2016/04/26 21:54:01
Suggestion: My inclination would be to define this
xunjieli
2016/07/20 21:00:47
Done.
|
| + public: |
| + virtual ~SdchStreamSourceDelegate(){}; |
| + |
| + // Called by the SdchStreamSource if an error occurs while parsing the |
| + // server-sent dictionary ID, or if the specified dictionary can't be loaded |
| + // (i.e., GetDictionary returned false). This method is expected to correct |
| + // the error condition by either: |
| + // a) returning true and calling ReplaceOutput or Passthrough, or |
| + // b) returning false, in which case the StreamSource will return an error |
| + // to its caller |
| + // Conceptually, the return value is true if the error has been |
| + // handled/recovered from and false if not. |
| + // This method must not retain a reference to |source| after returning. |
| + virtual bool HandleDictionaryError(SdchStreamSource* source) = 0; |
| + |
| + // Called by the SdchStreamSource if an error occurs while decoding the |
| + // vcdiff-compressed data stream. Semantics are similar to |
| + // HandleDictionaryError above. This method must not retain a reference to |
| + // |source| after returning. |
| + virtual bool HandleDecodingError(SdchStreamSource* source) = 0; |
| + |
| + // Called by the SdchStreamSource to request the text of the specified |
| + // dictionary. This method must either: |
| + // * Fill in |*text| and return true, or |
| + // * Leave |*text| untouched and return false. |
| + // The return value is true if the named dictionary could be found and false |
| + // otherwise. |
| + // |
| + // The |server_id| string is guaranteed to be a syntactically valid SDCH |
| + // server-id. |
| + virtual bool GetDictionary(const std::string& server_id, |
| + const std::string** text) = 0; |
| + |
| + // Called by the SdchStreamSource to notify the delegate that the stream |
| + // finished successfully. This method is purely advisory for statistics |
| + // gathering. |
| + virtual void NotifyStreamDone() = 0; |
| +}; |
| + |
| +} // namespace net |
| + |
| +#endif // NET_FILTER_SDCH_STREAM_SOURCE_DELEGATE_H_ |