Commit 04b63e7c authored by gab's avatar gab Committed by Commit Bot

Replace deprecated base::NonThreadSafe in chrome/service in favor of SequenceChecker.

Note to crash team: This CL is a refactor and has no intended behavior change.

This change was scripted by https://crbug.com/676387#c8.

Note-worthy for the reviewer:
 * SequenceChecker enforces thread-safety but not thread-affinity!
   If the classes that were updated are thread-affine (use thread local
   storage or a third-party API that does) they should be migrated to
   ThreadChecker instead.
 * ~NonThreadSafe() used to implcitly check in its destructor
   ~Sequence/ThreadChecker() doesn't by design. To keep this CL a
   no-op, an explicit check was added to the destructor of migrated
   classes.
 * NonThreadSafe used to provide access to subclasses, as such
   the |sequence_checker_| member was made protected rather than
   private where necessary.

BUG=676387
This CL was uploaded by git cl split.

R=scottbyer@chromium.org

Review-Url: https://codereview.chromium.org/2914573002
Cr-Commit-Position: refs/heads/master@{#476374}
parent a4b7c0e0
......@@ -33,19 +33,19 @@ CloudPrintProxy::CloudPrintProxy()
}
CloudPrintProxy::~CloudPrintProxy() {
DCHECK(CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ShutdownBackend();
}
void CloudPrintProxy::Initialize(ServiceProcessPrefs* service_prefs,
Client* client) {
DCHECK(CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
service_prefs_ = service_prefs;
client_ = client;
}
void CloudPrintProxy::EnableForUser() {
DCHECK(CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!CreateBackend())
return;
DCHECK(backend_.get());
......@@ -78,7 +78,7 @@ void CloudPrintProxy::EnableForUserWithRobot(
const std::string& robot_email,
const std::string& user_email,
const base::DictionaryValue& user_settings) {
DCHECK(CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ShutdownBackend();
std::string proxy_id(
......@@ -103,7 +103,7 @@ void CloudPrintProxy::EnableForUserWithRobot(
}
bool CloudPrintProxy::CreateBackend() {
DCHECK(CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (backend_.get())
return false;
......@@ -127,7 +127,7 @@ bool CloudPrintProxy::CreateBackend() {
}
void CloudPrintProxy::UnregisterPrintersAndDisableForUser() {
DCHECK(CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (backend_.get()) {
// Try getting auth and printers info from the backend.
// We'll get notified in this case.
......@@ -139,7 +139,7 @@ void CloudPrintProxy::UnregisterPrintersAndDisableForUser() {
}
void CloudPrintProxy::DisableForUser() {
DCHECK(CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
user_email_.clear();
enabled_ = false;
if (client_) {
......@@ -178,7 +178,7 @@ void CloudPrintProxy::OnAuthenticated(
const std::string& robot_oauth_refresh_token,
const std::string& robot_email,
const std::string& user_email) {
DCHECK(CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
service_prefs_->SetString(prefs::kCloudPrintRobotRefreshToken,
robot_oauth_refresh_token);
service_prefs_->SetString(prefs::kCloudPrintRobotEmail,
......@@ -203,7 +203,7 @@ void CloudPrintProxy::OnAuthenticated(
}
void CloudPrintProxy::OnAuthenticationFailed() {
DCHECK(CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Don't disable permanently. Could be just connection issue.
ShutdownBackend();
if (client_) {
......@@ -233,7 +233,7 @@ void CloudPrintProxy::OnUnregisterPrinters(
}
void CloudPrintProxy::OnXmppPingUpdated(int ping_timeout) {
DCHECK(CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
service_prefs_->SetInt(prefs::kCloudPrintXmppPingTimeout, ping_timeout);
service_prefs_->WritePrefs();
}
......@@ -245,7 +245,7 @@ void CloudPrintProxy::OnUnregisterPrintersComplete() {
}
void CloudPrintProxy::ShutdownBackend() {
DCHECK(CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (backend_.get())
backend_->Shutdown();
backend_.reset();
......
......@@ -11,7 +11,7 @@
#include <vector>
#include "base/macros.h"
#include "base/threading/non_thread_safe.h"
#include "base/sequence_checker.h"
#include "chrome/service/cloud_print/cloud_print_proxy_backend.h"
#include "chrome/service/cloud_print/cloud_print_wipeout.h"
......@@ -24,8 +24,7 @@ struct CloudPrintProxyInfo;
// CloudPrintProxy is the layer between the service process UI thread
// and the cloud print proxy backend.
class CloudPrintProxy : public CloudPrintProxyFrontend,
public CloudPrintWipeout::Client,
public base::NonThreadSafe {
public CloudPrintWipeout::Client {
public:
class Client {
public:
......@@ -99,6 +98,8 @@ class CloudPrintProxy : public CloudPrintProxyFrontend,
// This is a cleanup class for unregistering printers on proxy disable.
std::unique_ptr<CloudPrintWipeout> wipeout_;
SEQUENCE_CHECKER(sequence_checker_);
DISALLOW_COPY_AND_ASSIGN(CloudPrintProxy);
};
......
......@@ -24,11 +24,12 @@ CloudPrintTokenStore::CloudPrintTokenStore() {
}
CloudPrintTokenStore::~CloudPrintTokenStore() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
lazy_tls.Pointer()->Set(NULL);
}
void CloudPrintTokenStore::SetToken(const std::string& token) {
DCHECK(CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
token_ = token;
}
......
......@@ -8,14 +8,14 @@
#include <string>
#include "base/logging.h"
#include "base/macros.h"
#include "base/threading/non_thread_safe.h"
#include "base/sequence_checker.h"
// This class serves as the single repository for cloud print auth tokens. This
// is only used within the CloudPrintProxyCoreThread.
namespace cloud_print {
class CloudPrintTokenStore : public base::NonThreadSafe {
class CloudPrintTokenStore {
public:
// Returns the CloudPrintTokenStore instance for this thread. Will be NULL
// if no instance was created in this thread before.
......@@ -26,13 +26,15 @@ class CloudPrintTokenStore : public base::NonThreadSafe {
void SetToken(const std::string& token);
std::string token() const {
DCHECK(CalledOnValidThread());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return token_;
}
private:
std::string token_;
SEQUENCE_CHECKER(sequence_checker_);
DISALLOW_COPY_AND_ASSIGN(CloudPrintTokenStore);
};
......
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