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

Side by Side Diff: components/subresource_filter/core/common/unindexed_ruleset.h

Issue 2279803002: Fix UnindexedRulesetWriter finishing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove redundant test. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Semantically speaking, an unindexed ruleset consists of a single 5 // Semantically speaking, an unindexed ruleset consists of a single
6 // proto::FilteringRules message. However, because the ruleset can be relatively 6 // proto::FilteringRules message. However, because the ruleset can be relatively
7 // large, we want to avoid deserializing all of it at once, as doing so can lead 7 // large, we want to avoid deserializing all of it at once, as doing so can lead
8 // to memory allocation bursts. 8 // to memory allocation bursts.
9 // 9 //
10 // To work around the limitation that partial (or streaming) deserialization is 10 // To work around the limitation that partial (or streaming) deserialization is
(...skipping 24 matching lines...) Expand all
35 // Note: The |stream| should outlive |this| instance. 35 // Note: The |stream| should outlive |this| instance.
36 explicit UnindexedRulesetReader( 36 explicit UnindexedRulesetReader(
37 google::protobuf::io::ZeroCopyInputStream* stream); 37 google::protobuf::io::ZeroCopyInputStream* stream);
38 ~UnindexedRulesetReader(); 38 ~UnindexedRulesetReader();
39 39
40 // Reads the next ruleset |chunk| from the |input|. Returns false iff reached 40 // Reads the next ruleset |chunk| from the |input|. Returns false iff reached
41 // the end of the stream or an error occurred. Once returned false, calling 41 // the end of the stream or an error occurred. Once returned false, calling
42 // ReadNextChunk is undefined befaviour. 42 // ReadNextChunk is undefined befaviour.
43 bool ReadNextChunk(proto::FilteringRules* chunk); 43 bool ReadNextChunk(proto::FilteringRules* chunk);
44 44
45 // Returns how many bytes of the |stream| have been consumed.
46 int num_bytes_read() const { return coded_stream_.CurrentPosition(); }
47
45 private: 48 private:
46 google::protobuf::io::CodedInputStream coded_stream_; 49 google::protobuf::io::CodedInputStream coded_stream_;
47 50
48 DISALLOW_COPY_AND_ASSIGN(UnindexedRulesetReader); 51 DISALLOW_COPY_AND_ASSIGN(UnindexedRulesetReader);
49 }; 52 };
50 53
51 // Divides an unindexed ruleset into chunks and writes them into |stream|. 54 // Divides an unindexed ruleset into chunks and writes them into |stream|.
52 // 55 //
53 // Writing methods of this class return bool false if an I/O error occurrs 56 // Writing methods of this class return bool false if an I/O error occurrs
54 // during these calls. In this case the UnindexedRulesetWriter becomes broken, 57 // during these calls. In this case the UnindexedRulesetWriter becomes broken,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 91
89 const int max_rules_per_chunk_ = 0; 92 const int max_rules_per_chunk_ = 0;
90 proto::FilteringRules pending_chunk_; 93 proto::FilteringRules pending_chunk_;
91 94
92 DISALLOW_COPY_AND_ASSIGN(UnindexedRulesetWriter); 95 DISALLOW_COPY_AND_ASSIGN(UnindexedRulesetWriter);
93 }; 96 };
94 97
95 } // namespace subresource_filter 98 } // namespace subresource_filter
96 99
97 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_UNINDEXED_RULESET_H_ 100 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_UNINDEXED_RULESET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698