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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_util.h

Issue 1420053005: Move code in components/safe_browsing_db and chrome/browser/s_b/ under the safe_browsing namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@02_components_move
Patch Set: Remove '// namespace safe_browsing' for a small fwd decl block. Created 5 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Utilities for the SafeBrowsing code. 5 // Utilities for the SafeBrowsing code.
6 6
7 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_ 7 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_
8 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_ 8 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_
9 9
10 #include <cstring> 10 #include <cstring>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/strings/string_piece.h" 16 #include "base/strings/string_piece.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "chrome/browser/safe_browsing/chunk_range.h" 18 #include "chrome/browser/safe_browsing/chunk_range.h"
19 #include "components/safe_browsing_db/util.h" 19 #include "components/safe_browsing_db/util.h"
20 20
21 namespace safe_browsing { 21 namespace safe_browsing {
22
22 class ChunkData; 23 class ChunkData;
23 };
24 24
25 // Container for holding a chunk URL and the list it belongs to. 25 // Container for holding a chunk URL and the list it belongs to.
26 struct ChunkUrl { 26 struct ChunkUrl {
27 std::string url; 27 std::string url;
28 std::string list_name; 28 std::string list_name;
29 }; 29 };
30 30
31 // Data for an individual chunk sent from the server. 31 // Data for an individual chunk sent from the server.
32 class SBChunkData { 32 class SBChunkData {
33 public: 33 public:
34 SBChunkData(); 34 SBChunkData();
35 ~SBChunkData(); 35 ~SBChunkData();
36 36
37 // Create with manufactured data, for testing only. 37 // Create with manufactured data, for testing only.
38 // TODO(shess): Right now the test code calling this is in an anonymous 38 // TODO(shess): Right now the test code calling this is in an anonymous
39 // namespace. Figure out how to shift this into private:. 39 // namespace. Figure out how to shift this into private:.
40 explicit SBChunkData(safe_browsing::ChunkData* chunk_data); 40 explicit SBChunkData(ChunkData* chunk_data);
41 41
42 // Read serialized ChunkData, returning true if the parse suceeded. 42 // Read serialized ChunkData, returning true if the parse suceeded.
43 bool ParseFrom(const unsigned char* data, size_t length); 43 bool ParseFrom(const unsigned char* data, size_t length);
44 44
45 // Access the chunk data. |AddChunkNumberAt()| can only be called if 45 // Access the chunk data. |AddChunkNumberAt()| can only be called if
46 // |IsSub()| returns true. |Prefix*()| and |FullHash*()| can only be called 46 // |IsSub()| returns true. |Prefix*()| and |FullHash*()| can only be called
47 // if the corrosponding |Is*()| returned true. 47 // if the corrosponding |Is*()| returned true.
48 int ChunkNumber() const; 48 int ChunkNumber() const;
49 bool IsAdd() const; 49 bool IsAdd() const;
50 bool IsSub() const; 50 bool IsSub() const;
51 int AddChunkNumberAt(size_t i) const; 51 int AddChunkNumberAt(size_t i) const;
52 bool IsPrefix() const; 52 bool IsPrefix() const;
53 size_t PrefixCount() const; 53 size_t PrefixCount() const;
54 SBPrefix PrefixAt(size_t i) const; 54 SBPrefix PrefixAt(size_t i) const;
55 bool IsFullHash() const; 55 bool IsFullHash() const;
56 size_t FullHashCount() const; 56 size_t FullHashCount() const;
57 SBFullHash FullHashAt(size_t i) const; 57 SBFullHash FullHashAt(size_t i) const;
58 58
59 private: 59 private:
60 // Protocol buffer sent from server. 60 // Protocol buffer sent from server.
61 scoped_ptr<safe_browsing::ChunkData> chunk_data_; 61 scoped_ptr<ChunkData> chunk_data_;
62 62
63 DISALLOW_COPY_AND_ASSIGN(SBChunkData); 63 DISALLOW_COPY_AND_ASSIGN(SBChunkData);
64 }; 64 };
65 65
66 // Contains information about a list in the database. 66 // Contains information about a list in the database.
67 struct SBListChunkRanges { 67 struct SBListChunkRanges {
68 explicit SBListChunkRanges(const std::string& n); 68 explicit SBListChunkRanges(const std::string& n);
69 69
70 std::string name; // The list name. 70 std::string name; // The list name.
71 std::string adds; // The ranges for add chunks. 71 std::string adds; // The ranges for add chunks.
72 std::string subs; // The ranges for sub chunks. 72 std::string subs; // The ranges for sub chunks.
73 }; 73 };
74 74
75 // Container for deleting chunks from the database. 75 // Container for deleting chunks from the database.
76 struct SBChunkDelete { 76 struct SBChunkDelete {
77 SBChunkDelete(); 77 SBChunkDelete();
78 ~SBChunkDelete(); 78 ~SBChunkDelete();
79 79
80 std::string list_name; 80 std::string list_name;
81 bool is_sub_del; 81 bool is_sub_del;
82 std::vector<ChunkRange> chunk_del; 82 std::vector<ChunkRange> chunk_del;
83 }; 83 };
84 84
85 } // namespace safe_browsing
86
85 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_ 87 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_test.cc ('k') | chrome/browser/safe_browsing/safe_browsing_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698