OLD | NEW |
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/profile_sync_service.h" | 5 #include "components/browser_sync/profile_sync_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 #include <map> | 10 #include <map> |
(...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2103 const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback); | 2103 const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback); |
2104 | 2104 |
2105 void OnReceivedNodesForType(const syncer::ModelType type, | 2105 void OnReceivedNodesForType(const syncer::ModelType type, |
2106 std::unique_ptr<base::ListValue> node_list); | 2106 std::unique_ptr<base::ListValue> node_list); |
2107 | 2107 |
2108 private: | 2108 private: |
2109 friend class base::RefCountedThreadSafe<GetAllNodesRequestHelper>; | 2109 friend class base::RefCountedThreadSafe<GetAllNodesRequestHelper>; |
2110 virtual ~GetAllNodesRequestHelper(); | 2110 virtual ~GetAllNodesRequestHelper(); |
2111 | 2111 |
2112 std::unique_ptr<base::ListValue> result_accumulator_; | 2112 std::unique_ptr<base::ListValue> result_accumulator_; |
2113 | |
2114 syncer::ModelTypeSet awaiting_types_; | 2113 syncer::ModelTypeSet awaiting_types_; |
2115 base::Callback<void(std::unique_ptr<base::ListValue>)> callback_; | 2114 base::Callback<void(std::unique_ptr<base::ListValue>)> callback_; |
| 2115 base::ThreadChecker thread_checker_; |
| 2116 |
| 2117 DISALLOW_COPY_AND_ASSIGN(GetAllNodesRequestHelper); |
2116 }; | 2118 }; |
2117 | 2119 |
2118 GetAllNodesRequestHelper::GetAllNodesRequestHelper( | 2120 GetAllNodesRequestHelper::GetAllNodesRequestHelper( |
2119 syncer::ModelTypeSet requested_types, | 2121 syncer::ModelTypeSet requested_types, |
2120 const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback) | 2122 const base::Callback<void(std::unique_ptr<base::ListValue>)>& callback) |
2121 : result_accumulator_(new base::ListValue()), | 2123 : result_accumulator_(new base::ListValue()), |
2122 awaiting_types_(requested_types), | 2124 awaiting_types_(requested_types), |
2123 callback_(callback) {} | 2125 callback_(callback) {} |
2124 | 2126 |
2125 GetAllNodesRequestHelper::~GetAllNodesRequestHelper() { | 2127 GetAllNodesRequestHelper::~GetAllNodesRequestHelper() { |
2126 if (!awaiting_types_.Empty()) { | 2128 if (!awaiting_types_.Empty()) { |
2127 DLOG(WARNING) | 2129 DLOG(WARNING) |
2128 << "GetAllNodesRequest deleted before request was fulfilled. " | 2130 << "GetAllNodesRequest deleted before request was fulfilled. " |
2129 << "Missing types are: " << ModelTypeSetToString(awaiting_types_); | 2131 << "Missing types are: " << ModelTypeSetToString(awaiting_types_); |
2130 } | 2132 } |
2131 } | 2133 } |
2132 | 2134 |
2133 // Called when the set of nodes for a type has been returned. | 2135 // Called when the set of nodes for a type has been returned. |
2134 // Only return one type of nodes each time. | 2136 // Only return one type of nodes each time. |
2135 void GetAllNodesRequestHelper::OnReceivedNodesForType( | 2137 void GetAllNodesRequestHelper::OnReceivedNodesForType( |
2136 const syncer::ModelType type, | 2138 const syncer::ModelType type, |
2137 std::unique_ptr<base::ListValue> node_list) { | 2139 std::unique_ptr<base::ListValue> node_list) { |
| 2140 DCHECK(thread_checker_.CalledOnValidThread()); |
| 2141 |
2138 // Add these results to our list. | 2142 // Add these results to our list. |
2139 std::unique_ptr<base::DictionaryValue> type_dict(new base::DictionaryValue()); | 2143 std::unique_ptr<base::DictionaryValue> type_dict(new base::DictionaryValue()); |
2140 type_dict->SetString("type", ModelTypeToString(type)); | 2144 type_dict->SetString("type", ModelTypeToString(type)); |
2141 type_dict->Set("nodes", std::move(node_list)); | 2145 type_dict->Set("nodes", std::move(node_list)); |
2142 result_accumulator_->Append(std::move(type_dict)); | 2146 result_accumulator_->Append(std::move(type_dict)); |
2143 | 2147 |
2144 // Remember that this part of the request is satisfied. | 2148 // Remember that this part of the request is satisfied. |
2145 awaiting_types_.Remove(type); | 2149 awaiting_types_.Remove(type); |
2146 | 2150 |
2147 if (awaiting_types_.Empty()) { | 2151 if (awaiting_types_.Empty()) { |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2446 return; | 2450 return; |
2447 | 2451 |
2448 DCHECK(startup_controller_->IsSetupInProgress()); | 2452 DCHECK(startup_controller_->IsSetupInProgress()); |
2449 startup_controller_->SetSetupInProgress(false); | 2453 startup_controller_->SetSetupInProgress(false); |
2450 | 2454 |
2451 if (IsEngineInitialized()) | 2455 if (IsEngineInitialized()) |
2452 ReconfigureDatatypeManager(); | 2456 ReconfigureDatatypeManager(); |
2453 NotifyObservers(); | 2457 NotifyObservers(); |
2454 } | 2458 } |
2455 } // namespace browser_sync | 2459 } // namespace browser_sync |
OLD | NEW |