OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef SYNC_TEST_FAKE_SERVER_BOOKMARK_ENTITY_BUILDER_H_ | 5 #ifndef SYNC_TEST_FAKE_SERVER_BOOKMARK_ENTITY_BUILDER_H_ |
6 #define SYNC_TEST_FAKE_SERVER_BOOKMARK_ENTITY_BUILDER_H_ | 6 #define SYNC_TEST_FAKE_SERVER_BOOKMARK_ENTITY_BUILDER_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "sync/internal_api/public/base/model_type.h" | 11 #include "sync/internal_api/public/base/model_type.h" |
12 #include "sync/test/fake_server/fake_server_entity.h" | 12 #include "sync/test/fake_server/fake_server_entity.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 namespace fake_server { | 15 namespace fake_server { |
16 | 16 |
17 // Builder for BookmarkEntity objects. | 17 // Builder for BookmarkEntity objects. |
18 class BookmarkEntityBuilder { | 18 class BookmarkEntityBuilder { |
19 public: | 19 public: |
20 BookmarkEntityBuilder(const std::string& title, | 20 BookmarkEntityBuilder(const std::string& title, |
21 const std::string& originator_cache_guid, | 21 const std::string& originator_cache_guid, |
22 const std::string& originator_client_item_id); | 22 const std::string& originator_client_item_id); |
23 | 23 |
24 BookmarkEntityBuilder(const BookmarkEntityBuilder& other); | 24 BookmarkEntityBuilder(const BookmarkEntityBuilder& other); |
25 | 25 |
26 ~BookmarkEntityBuilder(); | 26 ~BookmarkEntityBuilder(); |
27 | 27 |
28 // Sets the parent ID of the bookmark to be built. If this is not called, | 28 // Sets the parent ID of the bookmark to be built. If this is not called, |
29 // the bookmark will be included in the bookmarks bar. | 29 // the bookmark will be included in the bookmarks bar. |
30 void SetParentId(const std::string& parent_id); | 30 void SetParentId(const std::string& parent_id); |
31 | 31 |
32 // Builds and returns a FakeServerEntity representing a bookmark. Returns null | 32 // Builds and returns a FakeServerEntity representing a bookmark. Returns null |
33 // if the entity could not be built. | 33 // if the entity could not be built. |
34 scoped_ptr<FakeServerEntity> BuildBookmark(const GURL& url); | 34 std::unique_ptr<FakeServerEntity> BuildBookmark(const GURL& url); |
35 | 35 |
36 // Builds and returns a FakeServerEntity representing a bookmark folder. | 36 // Builds and returns a FakeServerEntity representing a bookmark folder. |
37 // Returns null if the entity could not be built. | 37 // Returns null if the entity could not be built. |
38 scoped_ptr<FakeServerEntity> BuildFolder(); | 38 std::unique_ptr<FakeServerEntity> BuildFolder(); |
39 | 39 |
40 private: | 40 private: |
41 // Creates an EntitySpecifics and pre-populates its BookmarkSpecifics with | 41 // Creates an EntitySpecifics and pre-populates its BookmarkSpecifics with |
42 // the entity's title. | 42 // the entity's title. |
43 sync_pb::EntitySpecifics CreateBaseEntitySpecifics() const; | 43 sync_pb::EntitySpecifics CreateBaseEntitySpecifics() const; |
44 | 44 |
45 // Builds the parts of a FakeServerEntity common to both normal bookmarks and | 45 // Builds the parts of a FakeServerEntity common to both normal bookmarks and |
46 // folders. | 46 // folders. |
47 scoped_ptr<FakeServerEntity> Build( | 47 std::unique_ptr<FakeServerEntity> Build( |
48 const sync_pb::EntitySpecifics& entity_specifics, | 48 const sync_pb::EntitySpecifics& entity_specifics, |
49 bool is_folder); | 49 bool is_folder); |
50 | 50 |
51 // The bookmark entity's title. This value is also used as the entity's name. | 51 // The bookmark entity's title. This value is also used as the entity's name. |
52 const std::string title_; | 52 const std::string title_; |
53 | 53 |
54 // Information that associates the bookmark with its original client. | 54 // Information that associates the bookmark with its original client. |
55 const std::string originator_cache_guid_; | 55 const std::string originator_cache_guid_; |
56 const std::string originator_client_item_id_; | 56 const std::string originator_client_item_id_; |
57 | 57 |
58 // The ID of the parent bookmark folder. | 58 // The ID of the parent bookmark folder. |
59 std::string parent_id_; | 59 std::string parent_id_; |
60 }; | 60 }; |
61 | 61 |
62 } // namespace fake_server | 62 } // namespace fake_server |
63 | 63 |
64 #endif // SYNC_TEST_FAKE_SERVER_BOOKMARK_ENTITY_BUILDER_H_ | 64 #endif // SYNC_TEST_FAKE_SERVER_BOOKMARK_ENTITY_BUILDER_H_ |
OLD | NEW |