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

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

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