Index: chrome/browser/services/gcm/gcm_driver.cc |
diff --git a/chrome/browser/services/gcm/gcm_driver.cc b/chrome/browser/services/gcm/gcm_driver.cc |
index a855a18eeb09066ada4fe2961226ec6ca1a21c29..59860c01a787ff6c2864652392293705e62c5cdf 100644 |
--- a/chrome/browser/services/gcm/gcm_driver.cc |
+++ b/chrome/browser/services/gcm/gcm_driver.cc |
@@ -17,7 +17,6 @@ |
#include "components/gcm_driver/gcm_app_handler.h" |
#include "components/gcm_driver/gcm_client_factory.h" |
#include "components/gcm_driver/system_encryptor.h" |
-#include "content/public/browser/browser_thread.h" |
#include "google_apis/gaia/oauth2_token_service.h" |
#include "google_apis/gcm/protocol/android_checkin.pb.h" |
#include "net/url_request/url_request_context_getter.h" |
@@ -126,7 +125,8 @@ void GCMDriver::DelayedTaskController::RunTasks() { |
class GCMDriver::IOWorker : public GCMClient::Delegate { |
public: |
// Called on UI thread. |
- IOWorker(); |
+ IOWorker(const scoped_refptr<base::SequencedTaskRunner>& ui_thread, |
+ const scoped_refptr<base::SequencedTaskRunner>& io_thread); |
virtual ~IOWorker(); |
// Overridden from GCMClient::Delegate: |
@@ -150,11 +150,12 @@ class GCMDriver::IOWorker : public GCMClient::Delegate { |
virtual void OnActivityRecorded() OVERRIDE; |
// Called on IO thread. |
- void Initialize(scoped_ptr<GCMClientFactory> gcm_client_factory, |
- const base::FilePath& store_path, |
- const std::vector<std::string>& account_ids, |
- const scoped_refptr<net::URLRequestContextGetter>& |
- url_request_context_getter); |
+ void Initialize( |
+ scoped_ptr<GCMClientFactory> gcm_client_factory, |
+ const base::FilePath& store_path, |
+ const std::vector<std::string>& account_ids, |
+ const scoped_refptr<net::URLRequestContextGetter>& request_context, |
+ const scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); |
void Start(const base::WeakPtr<GCMDriver>& service); |
void Stop(); |
void CheckOut(); |
@@ -171,6 +172,9 @@ class GCMDriver::IOWorker : public GCMClient::Delegate { |
GCMClient* gcm_client_for_testing() const { return gcm_client_.get(); } |
private: |
+ scoped_refptr<base::SequencedTaskRunner> ui_thread_; |
+ scoped_refptr<base::SequencedTaskRunner> io_thread_; |
+ |
base::WeakPtr<GCMDriver> service_; |
scoped_ptr<GCMClient> gcm_client_; |
@@ -178,21 +182,25 @@ class GCMDriver::IOWorker : public GCMClient::Delegate { |
DISALLOW_COPY_AND_ASSIGN(IOWorker); |
}; |
-GCMDriver::IOWorker::IOWorker() { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+GCMDriver::IOWorker::IOWorker( |
+ const scoped_refptr<base::SequencedTaskRunner>& ui_thread, |
+ const scoped_refptr<base::SequencedTaskRunner>& io_thread) |
+ : ui_thread_(ui_thread), |
+ io_thread_(io_thread) { |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
} |
GCMDriver::IOWorker::~IOWorker() { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
} |
void GCMDriver::IOWorker::Initialize( |
scoped_ptr<GCMClientFactory> gcm_client_factory, |
const base::FilePath& store_path, |
const std::vector<std::string>& account_ids, |
- const scoped_refptr<net::URLRequestContextGetter>& |
- url_request_context_getter) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ const scoped_refptr<net::URLRequestContextGetter>& request_context, |
+ const scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) { |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
gcm_client_ = gcm_client_factory->BuildInstance(); |
@@ -201,18 +209,11 @@ void GCMDriver::IOWorker::Initialize( |
chrome_build_proto.set_chrome_version(GetVersion()); |
chrome_build_proto.set_channel(GetChannel()); |
- scoped_refptr<base::SequencedWorkerPool> worker_pool( |
- content::BrowserThread::GetBlockingPool()); |
- scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( |
- worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( |
- worker_pool->GetSequenceToken(), |
- base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
- |
gcm_client_->Initialize(chrome_build_proto, |
store_path, |
account_ids, |
blocking_task_runner, |
- url_request_context_getter, |
+ request_context, |
make_scoped_ptr<Encryptor>(new SystemEncryptor), |
this); |
} |
@@ -221,23 +222,19 @@ void GCMDriver::IOWorker::OnRegisterFinished( |
const std::string& app_id, |
const std::string& registration_id, |
GCMClient::Result result) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
- content::BrowserThread::PostTask(content::BrowserThread::UI, |
- FROM_HERE, |
- base::Bind(&GCMDriver::RegisterFinished, |
- service_, |
- app_id, |
- registration_id, |
- result)); |
+ ui_thread_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&GCMDriver::RegisterFinished, service_, app_id, |
+ registration_id, result)); |
} |
void GCMDriver::IOWorker::OnUnregisterFinished(const std::string& app_id, |
GCMClient::Result result) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
- content::BrowserThread::PostTask( |
- content::BrowserThread::UI, |
+ ui_thread_->PostTask( |
FROM_HERE, |
base::Bind(&GCMDriver::UnregisterFinished, service_, app_id, result)); |
} |
@@ -245,82 +242,71 @@ void GCMDriver::IOWorker::OnUnregisterFinished(const std::string& app_id, |
void GCMDriver::IOWorker::OnSendFinished(const std::string& app_id, |
const std::string& message_id, |
GCMClient::Result result) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
- content::BrowserThread::PostTask(content::BrowserThread::UI, |
- FROM_HERE, |
- base::Bind(&GCMDriver::SendFinished, |
- service_, |
- app_id, |
- message_id, |
- result)); |
+ ui_thread_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&GCMDriver::SendFinished, service_, app_id, message_id, |
+ result)); |
} |
void GCMDriver::IOWorker::OnMessageReceived( |
const std::string& app_id, |
const GCMClient::IncomingMessage& message) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
- content::BrowserThread::PostTask(content::BrowserThread::UI, |
- FROM_HERE, |
- base::Bind(&GCMDriver::MessageReceived, |
- service_, |
- app_id, |
- message)); |
+ ui_thread_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&GCMDriver::MessageReceived, service_, app_id, message)); |
} |
void GCMDriver::IOWorker::OnMessagesDeleted(const std::string& app_id) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
- content::BrowserThread::PostTask(content::BrowserThread::UI, |
- FROM_HERE, |
- base::Bind(&GCMDriver::MessagesDeleted, |
- service_, |
- app_id)); |
+ ui_thread_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&GCMDriver::MessagesDeleted, service_, app_id)); |
} |
void GCMDriver::IOWorker::OnMessageSendError( |
const std::string& app_id, |
const GCMClient::SendErrorDetails& send_error_details) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
- content::BrowserThread::PostTask(content::BrowserThread::UI, |
- FROM_HERE, |
- base::Bind(&GCMDriver::MessageSendError, |
- service_, |
- app_id, |
- send_error_details)); |
+ ui_thread_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&GCMDriver::MessageSendError, service_, app_id, |
+ send_error_details)); |
} |
void GCMDriver::IOWorker::OnGCMReady() { |
- content::BrowserThread::PostTask(content::BrowserThread::UI, |
- FROM_HERE, |
- base::Bind(&GCMDriver::GCMClientReady, |
- service_)); |
+ ui_thread_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&GCMDriver::GCMClientReady, service_)); |
} |
void GCMDriver::IOWorker::OnActivityRecorded() { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
// When an activity is recorded, get all the stats and refresh the UI of |
// gcm-internals page. |
GetGCMStatistics(false); |
} |
void GCMDriver::IOWorker::Start(const base::WeakPtr<GCMDriver>& service) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
service_ = service; |
gcm_client_->Start(); |
} |
void GCMDriver::IOWorker::Stop() { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
gcm_client_->Stop(); |
} |
void GCMDriver::IOWorker::CheckOut() { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
gcm_client_->CheckOut(); |
@@ -331,13 +317,13 @@ void GCMDriver::IOWorker::CheckOut() { |
void GCMDriver::IOWorker::Register( |
const std::string& app_id, |
const std::vector<std::string>& sender_ids) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
gcm_client_->Register(app_id, sender_ids); |
} |
void GCMDriver::IOWorker::Unregister(const std::string& app_id) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
gcm_client_->Unregister(app_id); |
} |
@@ -345,13 +331,13 @@ void GCMDriver::IOWorker::Unregister(const std::string& app_id) { |
void GCMDriver::IOWorker::Send(const std::string& app_id, |
const std::string& receiver_id, |
const GCMClient::OutgoingMessage& message) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
gcm_client_->Send(app_id, receiver_id, message); |
} |
void GCMDriver::IOWorker::GetGCMStatistics(bool clear_logs) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
gcm::GCMClient::GCMStatistics stats; |
if (gcm_client_.get()) { |
@@ -360,14 +346,13 @@ void GCMDriver::IOWorker::GetGCMStatistics(bool clear_logs) { |
stats = gcm_client_->GetStatistics(); |
} |
- content::BrowserThread::PostTask( |
- content::BrowserThread::UI, |
+ ui_thread_->PostTask( |
FROM_HERE, |
base::Bind(&GCMDriver::GetGCMStatisticsFinished, service_, stats)); |
} |
void GCMDriver::IOWorker::SetGCMRecording(bool recording) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ DCHECK(io_thread_->RunsTasksOnCurrentThread()); |
gcm::GCMClient::GCMStatistics stats; |
if (gcm_client_.get()) { |
@@ -376,8 +361,7 @@ void GCMDriver::IOWorker::SetGCMRecording(bool recording) { |
stats.gcm_client_created = true; |
} |
- content::BrowserThread::PostTask( |
- content::BrowserThread::UI, |
+ ui_thread_->PostTask( |
FROM_HERE, |
base::Bind(&GCMDriver::GetGCMStatisticsFinished, service_, stats)); |
} |
@@ -386,10 +370,15 @@ GCMDriver::GCMDriver( |
scoped_ptr<GCMClientFactory> gcm_client_factory, |
scoped_ptr<IdentityProvider> identity_provider, |
const base::FilePath& store_path, |
- const scoped_refptr<net::URLRequestContextGetter>& request_context) |
+ const scoped_refptr<net::URLRequestContextGetter>& request_context, |
+ const scoped_refptr<base::SequencedTaskRunner>& ui_thread, |
+ const scoped_refptr<base::SequencedTaskRunner>& io_thread, |
+ const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) |
: gcm_enabled_(true), |
gcm_client_ready_(false), |
identity_provider_(identity_provider.Pass()), |
+ ui_thread_(ui_thread), |
+ io_thread_(io_thread), |
weak_ptr_factory_(this) { |
// Get the list of available accounts. |
std::vector<std::string> account_ids; |
@@ -399,16 +388,16 @@ GCMDriver::GCMDriver( |
// Create and initialize the GCMClient. Note that this does not initiate the |
// GCM check-in. |
- io_worker_.reset(new IOWorker()); |
- content::BrowserThread::PostTask( |
- content::BrowserThread::IO, |
+ io_worker_.reset(new IOWorker(ui_thread, io_thread)); |
+ io_thread_->PostTask( |
FROM_HERE, |
base::Bind(&GCMDriver::IOWorker::Initialize, |
base::Unretained(io_worker_.get()), |
base::Passed(&gcm_client_factory), |
store_path, |
account_ids, |
- request_context)); |
+ request_context, |
+ blocking_task_runner)); |
identity_provider_->AddObserver(this); |
} |
@@ -423,7 +412,7 @@ GCMDriver::~GCMDriver() { |
} |
void GCMDriver::Enable() { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
if (gcm_enabled_) |
return; |
@@ -433,7 +422,7 @@ void GCMDriver::Enable() { |
} |
void GCMDriver::Disable() { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
if (!gcm_enabled_) |
return; |
@@ -443,7 +432,7 @@ void GCMDriver::Disable() { |
} |
void GCMDriver::Stop() { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
// No need to stop GCM service if not started yet. |
if (account_id_.empty()) |
@@ -451,29 +440,26 @@ void GCMDriver::Stop() { |
RemoveCachedData(); |
- content::BrowserThread::PostTask( |
- content::BrowserThread::IO, |
+ io_thread_->PostTask( |
FROM_HERE, |
base::Bind(&GCMDriver::IOWorker::Stop, |
base::Unretained(io_worker_.get()))); |
} |
void GCMDriver::Shutdown() { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
identity_provider_->RemoveObserver(this); |
for (GCMAppHandlerMap::const_iterator iter = app_handlers_.begin(); |
iter != app_handlers_.end(); ++iter) { |
iter->second->ShutdownHandler(); |
} |
app_handlers_.clear(); |
- content::BrowserThread::DeleteSoon(content::BrowserThread::IO, |
- FROM_HERE, |
- io_worker_.release()); |
+ io_thread_->DeleteSoon(FROM_HERE, io_worker_.release()); |
} |
void GCMDriver::AddAppHandler(const std::string& app_id, |
GCMAppHandler* handler) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
DCHECK(!app_id.empty()); |
DCHECK(handler); |
DCHECK(app_handlers_.find(app_id) == app_handlers_.end()); |
@@ -485,7 +471,7 @@ void GCMDriver::AddAppHandler(const std::string& app_id, |
} |
void GCMDriver::RemoveAppHandler(const std::string& app_id) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
DCHECK(!app_id.empty()); |
app_handlers_.erase(app_id); |
@@ -494,7 +480,7 @@ void GCMDriver::RemoveAppHandler(const std::string& app_id) { |
void GCMDriver::Register(const std::string& app_id, |
const std::vector<std::string>& sender_ids, |
const RegisterCallback& callback) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
DCHECK(!app_id.empty()); |
DCHECK(!sender_ids.empty()); |
DCHECK(!callback.is_null()); |
@@ -527,7 +513,7 @@ void GCMDriver::Register(const std::string& app_id, |
void GCMDriver::DoRegister(const std::string& app_id, |
const std::vector<std::string>& sender_ids) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
std::map<std::string, RegisterCallback>::iterator callback_iter = |
register_callbacks_.find(app_id); |
if (callback_iter == register_callbacks_.end()) { |
@@ -539,8 +525,7 @@ void GCMDriver::DoRegister(const std::string& app_id, |
std::vector<std::string> normalized_sender_ids = sender_ids; |
std::sort(normalized_sender_ids.begin(), normalized_sender_ids.end()); |
- content::BrowserThread::PostTask( |
- content::BrowserThread::IO, |
+ io_thread_->PostTask( |
FROM_HERE, |
base::Bind(&GCMDriver::IOWorker::Register, |
base::Unretained(io_worker_.get()), |
@@ -550,7 +535,7 @@ void GCMDriver::DoRegister(const std::string& app_id, |
void GCMDriver::Unregister(const std::string& app_id, |
const UnregisterCallback& callback) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
DCHECK(!app_id.empty()); |
DCHECK(!callback.is_null()); |
@@ -580,13 +565,12 @@ void GCMDriver::Unregister(const std::string& app_id, |
} |
void GCMDriver::DoUnregister(const std::string& app_id) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
// Ask the server to unregister it. There could be a small chance that the |
// unregister request fails. If this occurs, it does not bring any harm since |
// we simply reject the messages/events received from the server. |
- content::BrowserThread::PostTask( |
- content::BrowserThread::IO, |
+ io_thread_->PostTask( |
FROM_HERE, |
base::Bind(&GCMDriver::IOWorker::Unregister, |
base::Unretained(io_worker_.get()), |
@@ -597,7 +581,7 @@ void GCMDriver::Send(const std::string& app_id, |
const std::string& receiver_id, |
const GCMClient::OutgoingMessage& message, |
const SendCallback& callback) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
DCHECK(!app_id.empty()); |
DCHECK(!receiver_id.empty()); |
DCHECK(!callback.is_null()); |
@@ -633,9 +617,8 @@ void GCMDriver::Send(const std::string& app_id, |
void GCMDriver::DoSend(const std::string& app_id, |
const std::string& receiver_id, |
const GCMClient::OutgoingMessage& message) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
- content::BrowserThread::PostTask( |
- content::BrowserThread::IO, |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
+ io_thread_->PostTask( |
FROM_HERE, |
base::Bind(&GCMDriver::IOWorker::Send, |
base::Unretained(io_worker_.get()), |
@@ -645,28 +628,27 @@ void GCMDriver::DoSend(const std::string& app_id, |
} |
GCMClient* GCMDriver::GetGCMClientForTesting() const { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
return io_worker_ ? io_worker_->gcm_client_for_testing() : NULL; |
} |
bool GCMDriver::IsStarted() const { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
return !account_id_.empty(); |
} |
bool GCMDriver::IsGCMClientReady() const { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
return gcm_client_ready_; |
} |
void GCMDriver::GetGCMStatistics(const GetGCMStatisticsCallback& callback, |
bool clear_logs) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
DCHECK(!callback.is_null()); |
request_gcm_statistics_callback_ = callback; |
- content::BrowserThread::PostTask( |
- content::BrowserThread::IO, |
+ io_thread_->PostTask( |
FROM_HERE, |
base::Bind(&GCMDriver::IOWorker::GetGCMStatistics, |
base::Unretained(io_worker_.get()), |
@@ -675,11 +657,10 @@ void GCMDriver::GetGCMStatistics(const GetGCMStatisticsCallback& callback, |
void GCMDriver::SetGCMRecording(const GetGCMStatisticsCallback& callback, |
bool recording) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
request_gcm_statistics_callback_ = callback; |
- content::BrowserThread::PostTask( |
- content::BrowserThread::IO, |
+ io_thread_->PostTask( |
FROM_HERE, |
base::Bind(&GCMDriver::IOWorker::SetGCMRecording, |
base::Unretained(io_worker_.get()), |
@@ -695,7 +676,7 @@ void GCMDriver::OnActiveAccountLogout() { |
} |
GCMClient::Result GCMDriver::EnsureStarted() { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
if (!gcm_enabled_) |
return GCMClient::GCM_DISABLED; |
@@ -717,8 +698,7 @@ GCMClient::Result GCMDriver::EnsureStarted() { |
// Note that we need to pass weak pointer again since the existing weak |
// pointer in IOWorker might have been invalidated when check-out occurs. |
- content::BrowserThread::PostTask( |
- content::BrowserThread::IO, |
+ io_thread_->PostTask( |
FROM_HERE, |
base::Bind(&GCMDriver::IOWorker::Start, |
base::Unretained(io_worker_.get()), |
@@ -728,7 +708,7 @@ GCMClient::Result GCMDriver::EnsureStarted() { |
} |
void GCMDriver::RemoveCachedData() { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
// Remove all the queued tasks since they no longer make sense after |
// GCM service is stopped. |
weak_ptr_factory_.InvalidateWeakPtrs(); |
@@ -741,7 +721,7 @@ void GCMDriver::RemoveCachedData() { |
} |
void GCMDriver::CheckOut() { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
// We still proceed with the check-out logic even if the check-in is not |
// initiated in the current session. This will make sure that all the |
@@ -749,15 +729,14 @@ void GCMDriver::CheckOut() { |
RemoveCachedData(); |
- content::BrowserThread::PostTask( |
- content::BrowserThread::IO, |
+ io_thread_->PostTask( |
FROM_HERE, |
base::Bind(&GCMDriver::IOWorker::CheckOut, |
base::Unretained(io_worker_.get()))); |
} |
bool GCMDriver::IsAsyncOperationPending(const std::string& app_id) const { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
return register_callbacks_.find(app_id) != register_callbacks_.end() || |
unregister_callbacks_.find(app_id) != unregister_callbacks_.end(); |
} |
@@ -765,7 +744,7 @@ bool GCMDriver::IsAsyncOperationPending(const std::string& app_id) const { |
void GCMDriver::RegisterFinished(const std::string& app_id, |
const std::string& registration_id, |
GCMClient::Result result) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
std::map<std::string, RegisterCallback>::iterator callback_iter = |
register_callbacks_.find(app_id); |
@@ -781,7 +760,7 @@ void GCMDriver::RegisterFinished(const std::string& app_id, |
void GCMDriver::UnregisterFinished(const std::string& app_id, |
GCMClient::Result result) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
std::map<std::string, UnregisterCallback>::iterator callback_iter = |
unregister_callbacks_.find(app_id); |
@@ -796,7 +775,7 @@ void GCMDriver::UnregisterFinished(const std::string& app_id, |
void GCMDriver::SendFinished(const std::string& app_id, |
const std::string& message_id, |
GCMClient::Result result) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
std::map<std::pair<std::string, std::string>, SendCallback>::iterator |
callback_iter = send_callbacks_.find( |
@@ -813,7 +792,7 @@ void GCMDriver::SendFinished(const std::string& app_id, |
void GCMDriver::MessageReceived(const std::string& app_id, |
GCMClient::IncomingMessage message) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
// Drop the event if signed out. |
if (account_id_.empty()) |
@@ -823,7 +802,7 @@ void GCMDriver::MessageReceived(const std::string& app_id, |
} |
void GCMDriver::MessagesDeleted(const std::string& app_id) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
// Drop the event if signed out. |
if (account_id_.empty()) |
@@ -835,7 +814,7 @@ void GCMDriver::MessagesDeleted(const std::string& app_id) { |
void GCMDriver::MessageSendError( |
const std::string& app_id, |
const GCMClient::SendErrorDetails& send_error_details) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
// Drop the event if signed out. |
if (account_id_.empty()) |
@@ -845,7 +824,7 @@ void GCMDriver::MessageSendError( |
} |
void GCMDriver::GCMClientReady() { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
if (gcm_client_ready_) |
return; |
@@ -855,7 +834,7 @@ void GCMDriver::GCMClientReady() { |
} |
GCMAppHandler* GCMDriver::GetAppHandler(const std::string& app_id) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
std::map<std::string, GCMAppHandler*>::const_iterator iter = |
app_handlers_.find(app_id); |
@@ -863,7 +842,7 @@ GCMAppHandler* GCMDriver::GetAppHandler(const std::string& app_id) { |
} |
void GCMDriver::GetGCMStatisticsFinished(GCMClient::GCMStatistics stats) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread()); |
// Normally request_gcm_statistics_callback_ would not be null. |
if (!request_gcm_statistics_callback_.is_null()) |