Commit 107e8641 authored by Mikel Astiz's avatar Mikel Astiz Committed by Commit Bot

Avoid calls to GetStatusCounters() while datatype NOT_RUNNING

This method, used for debugging (chrome://sync-internals), has no clear
semantics if a datatype hasn't been started. This is specially true with
future work in mind where we plan to introduce different operating modes
(regular vs ephemeral) that are bound to a start-stop configuration
cycle.

We also migrate away from callers having to use BindToCurrentSequence(),
since there seems to be no reason for it (and is really weird after
having recently introduced ModelTypeControllerDelegate).

Bug: 866814
Change-Id: I653e1ee117883feb42e032faac85d5ba14d28748
Reviewed-on: https://chromium-review.googlesource.com/1160229Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580141}
parent 1eb44c8a
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "components/signin/core/browser/account_info.h" #include "components/signin/core/browser/account_info.h"
#include "components/signin/core/browser/signin_manager.h" #include "components/signin/core/browser/signin_manager.h"
#include "components/signin/core/browser/signin_metrics.h" #include "components/signin/core/browser/signin_metrics.h"
#include "components/sync/base/bind_to_task_runner.h"
#include "components/sync/base/cryptographer.h" #include "components/sync/base/cryptographer.h"
#include "components/sync/base/passphrase_type.h" #include "components/sync/base/passphrase_type.h"
#include "components/sync/base/report_unrecoverable_error.h" #include "components/sync/base/report_unrecoverable_error.h"
...@@ -1659,15 +1658,14 @@ std::unique_ptr<base::Value> ProfileSyncService::GetTypeStatusMap() { ...@@ -1659,15 +1658,14 @@ std::unique_ptr<base::Value> ProfileSyncService::GetTypeStatusMap() {
const auto& dtc_iter = data_type_controllers_.find(type); const auto& dtc_iter = data_type_controllers_.find(type);
if (dtc_iter != data_type_controllers_.end()) { if (dtc_iter != data_type_controllers_.end()) {
// OnDatatypeStatusCounterUpdated that posts back to the UI thread so that
// real results can't get overwritten by the empty counters set at the end
// of this method.
dtc_iter->second->GetStatusCounters(
BindToCurrentSequence(base::BindRepeating(
&ProfileSyncService::OnDatatypeStatusCounterUpdated,
base::Unretained(this))));
type_status->SetString("state", DataTypeController::StateToString( type_status->SetString("state", DataTypeController::StateToString(
dtc_iter->second->state())); dtc_iter->second->state()));
if (dtc_iter->second->state() !=
syncer::DataTypeController::NOT_RUNNING) {
dtc_iter->second->GetStatusCounters(base::BindRepeating(
&ProfileSyncService::OnDatatypeStatusCounterUpdated,
base::Unretained(this)));
}
} }
result->Append(std::move(type_status)); result->Append(std::move(type_status));
......
...@@ -168,8 +168,7 @@ class DataTypeController : public base::SupportsWeakPtr<DataTypeController> { ...@@ -168,8 +168,7 @@ class DataTypeController : public base::SupportsWeakPtr<DataTypeController> {
// Used for populating nodes in Sync Node Browser of chrome://sync-internals. // Used for populating nodes in Sync Node Browser of chrome://sync-internals.
virtual void GetAllNodes(const AllNodesCallback& callback) = 0; virtual void GetAllNodes(const AllNodesCallback& callback) = 0;
// Collects StatusCounters for this datatype and passes them to |callback|, // Collects StatusCounters for this datatype and passes them to |callback|.
// which should be wrapped with syncer::BindToCurrentThread already.
// Used to display entity counts in chrome://sync-internals. // Used to display entity counts in chrome://sync-internals.
virtual void GetStatusCounters(const StatusCountersCallback& callback) = 0; virtual void GetStatusCounters(const StatusCountersCallback& callback) = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment