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

Side by Side Diff: components/bookmarks/managed/managed_bookmark_service.cc

Issue 1906973002: Convert //components/bookmarks from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "components/bookmarks/managed/managed_bookmark_service.h" 5 #include "components/bookmarks/managed/managed_bookmark_service.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 11 matching lines...) Expand all
22 #include "grit/components_strings.h" 22 #include "grit/components_strings.h"
23 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
24 24
25 namespace bookmarks { 25 namespace bookmarks {
26 namespace { 26 namespace {
27 27
28 // BookmarkPermanentNodeLoader initializes a BookmarkPermanentNode from a JSON 28 // BookmarkPermanentNodeLoader initializes a BookmarkPermanentNode from a JSON
29 // representation, title id and starting node id. 29 // representation, title id and starting node id.
30 class BookmarkPermanentNodeLoader { 30 class BookmarkPermanentNodeLoader {
31 public: 31 public:
32 BookmarkPermanentNodeLoader(scoped_ptr<BookmarkPermanentNode> node, 32 BookmarkPermanentNodeLoader(
33 scoped_ptr<base::ListValue> initial_bookmarks, 33 std::unique_ptr<BookmarkPermanentNode> node,
34 int title_id) 34 std::unique_ptr<base::ListValue> initial_bookmarks,
35 int title_id)
35 : node_(std::move(node)), 36 : node_(std::move(node)),
36 initial_bookmarks_(std::move(initial_bookmarks)), 37 initial_bookmarks_(std::move(initial_bookmarks)),
37 title_id_(title_id) { 38 title_id_(title_id) {
38 DCHECK(node_); 39 DCHECK(node_);
39 } 40 }
40 41
41 ~BookmarkPermanentNodeLoader() {} 42 ~BookmarkPermanentNodeLoader() {}
42 43
43 // Initializes |node_| from |initial_bookmarks_| and |title_id_| and returns 44 // Initializes |node_| from |initial_bookmarks_| and |title_id_| and returns
44 // it. The ids are assigned starting at |next_node_id| and the value is 45 // it. The ids are assigned starting at |next_node_id| and the value is
45 // updated as a side-effect. 46 // updated as a side-effect.
46 scoped_ptr<BookmarkPermanentNode> Load(int64_t* next_node_id) { 47 std::unique_ptr<BookmarkPermanentNode> Load(int64_t* next_node_id) {
47 node_->set_id(*next_node_id); 48 node_->set_id(*next_node_id);
48 *next_node_id = ManagedBookmarksTracker::LoadInitial( 49 *next_node_id = ManagedBookmarksTracker::LoadInitial(
49 node_.get(), initial_bookmarks_.get(), node_->id() + 1); 50 node_.get(), initial_bookmarks_.get(), node_->id() + 1);
50 node_->set_visible(!node_->empty()); 51 node_->set_visible(!node_->empty());
51 node_->SetTitle(l10n_util::GetStringUTF16(title_id_)); 52 node_->SetTitle(l10n_util::GetStringUTF16(title_id_));
52 return std::move(node_); 53 return std::move(node_);
53 } 54 }
54 55
55 private: 56 private:
56 scoped_ptr<BookmarkPermanentNode> node_; 57 std::unique_ptr<BookmarkPermanentNode> node_;
57 scoped_ptr<base::ListValue> initial_bookmarks_; 58 std::unique_ptr<base::ListValue> initial_bookmarks_;
58 int title_id_; 59 int title_id_;
59 60
60 DISALLOW_COPY_AND_ASSIGN(BookmarkPermanentNodeLoader); 61 DISALLOW_COPY_AND_ASSIGN(BookmarkPermanentNodeLoader);
61 }; 62 };
62 63
63 // Returns a list of initialized BookmarkPermanentNodes using |next_node_id| to 64 // Returns a list of initialized BookmarkPermanentNodes using |next_node_id| to
64 // start assigning id. |next_node_id| is updated as a side effect of calling 65 // start assigning id. |next_node_id| is updated as a side effect of calling
65 // this method. 66 // this method.
66 BookmarkPermanentNodeList LoadExtraNodes( 67 BookmarkPermanentNodeList LoadExtraNodes(
67 ScopedVector<BookmarkPermanentNodeLoader> loaders, 68 ScopedVector<BookmarkPermanentNodeLoader> loaders,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 101
101 GetManagementDomainCallback unbound_callback; 102 GetManagementDomainCallback unbound_callback;
102 supervised_bookmarks_tracker_.reset(new ManagedBookmarksTracker( 103 supervised_bookmarks_tracker_.reset(new ManagedBookmarksTracker(
103 bookmark_model_, prefs_, true /* is_supervised */, unbound_callback)); 104 bookmark_model_, prefs_, true /* is_supervised */, unbound_callback));
104 } 105 }
105 106
106 LoadExtraCallback ManagedBookmarkService::GetLoadExtraNodesCallback() { 107 LoadExtraCallback ManagedBookmarkService::GetLoadExtraNodesCallback() {
107 // Create two BookmarkPermanentNode with a temporary id of 0. They will be 108 // Create two BookmarkPermanentNode with a temporary id of 0. They will be
108 // populated and assigned proper ids in the LoadExtraNodes callback. Until 109 // populated and assigned proper ids in the LoadExtraNodes callback. Until
109 // then, they are owned by the returned closure. 110 // then, they are owned by the returned closure.
110 scoped_ptr<BookmarkPermanentNode> managed(new BookmarkPermanentNode(0)); 111 std::unique_ptr<BookmarkPermanentNode> managed(new BookmarkPermanentNode(0));
111 scoped_ptr<BookmarkPermanentNode> supervised(new BookmarkPermanentNode(0)); 112 std::unique_ptr<BookmarkPermanentNode> supervised(
113 new BookmarkPermanentNode(0));
112 114
113 managed_node_ = managed.get(); 115 managed_node_ = managed.get();
114 supervised_node_ = supervised.get(); 116 supervised_node_ = supervised.get();
115 117
116 ScopedVector<BookmarkPermanentNodeLoader> loaders; 118 ScopedVector<BookmarkPermanentNodeLoader> loaders;
117 loaders.push_back(new BookmarkPermanentNodeLoader( 119 loaders.push_back(new BookmarkPermanentNodeLoader(
118 std::move(managed), 120 std::move(managed),
119 managed_bookmarks_tracker_->GetInitialManagedBookmarks(), 121 managed_bookmarks_tracker_->GetInitialManagedBookmarks(),
120 IDS_BOOKMARK_BAR_MANAGED_FOLDER_DEFAULT_NAME)); 122 IDS_BOOKMARK_BAR_MANAGED_FOLDER_DEFAULT_NAME));
121 loaders.push_back(new BookmarkPermanentNodeLoader( 123 loaders.push_back(new BookmarkPermanentNodeLoader(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 179 }
178 180
179 managed_bookmarks_tracker_.reset(); 181 managed_bookmarks_tracker_.reset();
180 supervised_bookmarks_tracker_.reset(); 182 supervised_bookmarks_tracker_.reset();
181 183
182 managed_node_ = nullptr; 184 managed_node_ = nullptr;
183 supervised_node_ = nullptr; 185 supervised_node_ = nullptr;
184 } 186 }
185 187
186 } // namespace bookmarks 188 } // namespace bookmarks
OLDNEW
« no previous file with comments | « components/bookmarks/managed/managed_bookmark_service.h ('k') | components/bookmarks/managed/managed_bookmarks_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698