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

Side by Side Diff: components/browser_sync/browser/profile_sync_service.cc

Issue 2051663003: base::ListValue::Append cleanup: pass unique_ptr instead of the released pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 #include "components/browser_sync/browser/profile_sync_service.h" 5 #include "components/browser_sync/browser/profile_sync_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <cstddef> 8 #include <cstddef>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 ModelTypeSet& throttled_types(detailed_status.throttled_types); 1886 ModelTypeSet& throttled_types(detailed_status.throttled_types);
1887 ModelTypeSet registered = GetRegisteredDataTypes(); 1887 ModelTypeSet registered = GetRegisteredDataTypes();
1888 std::unique_ptr<base::DictionaryValue> type_status_header( 1888 std::unique_ptr<base::DictionaryValue> type_status_header(
1889 new base::DictionaryValue()); 1889 new base::DictionaryValue());
1890 1890
1891 type_status_header->SetString("name", "Model Type"); 1891 type_status_header->SetString("name", "Model Type");
1892 type_status_header->SetString("status", "header"); 1892 type_status_header->SetString("status", "header");
1893 type_status_header->SetString("value", "Group Type"); 1893 type_status_header->SetString("value", "Group Type");
1894 type_status_header->SetString("num_entries", "Total Entries"); 1894 type_status_header->SetString("num_entries", "Total Entries");
1895 type_status_header->SetString("num_live", "Live Entries"); 1895 type_status_header->SetString("num_live", "Live Entries");
1896 result->Append(type_status_header.release()); 1896 result->Append(std::move(type_status_header));
1897 1897
1898 std::unique_ptr<base::DictionaryValue> type_status; 1898 std::unique_ptr<base::DictionaryValue> type_status;
1899 for (ModelTypeSet::Iterator it = registered.First(); it.Good(); it.Inc()) { 1899 for (ModelTypeSet::Iterator it = registered.First(); it.Good(); it.Inc()) {
1900 ModelType type = it.Get(); 1900 ModelType type = it.Get();
1901 1901
1902 type_status.reset(new base::DictionaryValue()); 1902 type_status.reset(new base::DictionaryValue());
1903 type_status->SetString("name", ModelTypeToString(type)); 1903 type_status->SetString("name", ModelTypeToString(type));
1904 1904
1905 if (error_map.find(type) != error_map.end()) { 1905 if (error_map.find(type) != error_map.end()) {
1906 const syncer::SyncError &error = error_map.find(type)->second; 1906 const syncer::SyncError &error = error_map.find(type)->second;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 type_status->SetString("status", "warning"); 1943 type_status->SetString("status", "warning");
1944 type_status->SetString("value", "Disabled by User"); 1944 type_status->SetString("value", "Disabled by User");
1945 } 1945 }
1946 1946
1947 int live_count = detailed_status.num_entries_by_type[type] - 1947 int live_count = detailed_status.num_entries_by_type[type] -
1948 detailed_status.num_to_delete_entries_by_type[type]; 1948 detailed_status.num_to_delete_entries_by_type[type];
1949 type_status->SetInteger("num_entries", 1949 type_status->SetInteger("num_entries",
1950 detailed_status.num_entries_by_type[type]); 1950 detailed_status.num_entries_by_type[type]);
1951 type_status->SetInteger("num_live", live_count); 1951 type_status->SetInteger("num_live", live_count);
1952 1952
1953 result->Append(type_status.release()); 1953 result->Append(std::move(type_status));
1954 } 1954 }
1955 return result.release(); 1955 return result.release();
1956 } 1956 }
1957 1957
1958 void ProfileSyncService::ConsumeCachedPassphraseIfPossible() { 1958 void ProfileSyncService::ConsumeCachedPassphraseIfPossible() {
1959 // If no cached passphrase, or sync backend hasn't started up yet, just exit. 1959 // If no cached passphrase, or sync backend hasn't started up yet, just exit.
1960 // If the backend isn't running yet, OnBackendInitialized() will call this 1960 // If the backend isn't running yet, OnBackendInitialized() will call this
1961 // method again after the backend starts up. 1961 // method again after the backend starts up.
1962 if (cached_passphrase_.empty() || !IsBackendInitialized()) 1962 if (cached_passphrase_.empty() || !IsBackendInitialized())
1963 return; 1963 return;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
2263 2263
2264 for (size_t i = 0; i < node_lists.size() && i < types.size(); ++i) { 2264 for (size_t i = 0; i < node_lists.size() && i < types.size(); ++i) {
2265 const ModelType type = types[i]; 2265 const ModelType type = types[i];
2266 base::ListValue* node_list = node_lists[i]; 2266 base::ListValue* node_list = node_lists[i];
2267 2267
2268 // Add these results to our list. 2268 // Add these results to our list.
2269 std::unique_ptr<base::DictionaryValue> type_dict( 2269 std::unique_ptr<base::DictionaryValue> type_dict(
2270 new base::DictionaryValue()); 2270 new base::DictionaryValue());
2271 type_dict->SetString("type", ModelTypeToString(type)); 2271 type_dict->SetString("type", ModelTypeToString(type));
2272 type_dict->Set("nodes", node_list); 2272 type_dict->Set("nodes", node_list);
2273 result_accumulator_->Append(type_dict.release()); 2273 result_accumulator_->Append(std::move(type_dict));
2274 2274
2275 // Remember that this part of the request is satisfied. 2275 // Remember that this part of the request is satisfied.
2276 awaiting_types_.Remove(type); 2276 awaiting_types_.Remove(type);
2277 } 2277 }
2278 2278
2279 if (awaiting_types_.Empty()) { 2279 if (awaiting_types_.Empty()) {
2280 callback_.Run(std::move(result_accumulator_)); 2280 callback_.Run(std::move(result_accumulator_));
2281 callback_.Reset(); 2281 callback_.Reset();
2282 } 2282 }
2283 } 2283 }
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2535 } 2535 }
2536 2536
2537 std::string ProfileSyncService::unrecoverable_error_message() const { 2537 std::string ProfileSyncService::unrecoverable_error_message() const {
2538 return unrecoverable_error_message_; 2538 return unrecoverable_error_message_;
2539 } 2539 }
2540 2540
2541 tracked_objects::Location ProfileSyncService::unrecoverable_error_location() 2541 tracked_objects::Location ProfileSyncService::unrecoverable_error_location()
2542 const { 2542 const {
2543 return unrecoverable_error_location_; 2543 return unrecoverable_error_location_;
2544 } 2544 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698