weak_handle.cc 993 B

12345678910111213141516171819202122232425262728293031
  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
  3. // found in the LICENSE file.
  4. #include "components/sync/base/weak_handle.h"
  5. #include <sstream>
  6. #include "base/callback.h"
  7. #include "base/logging.h"
  8. #include "base/threading/sequenced_task_runner_handle.h"
  9. namespace syncer::internal {
  10. WeakHandleCoreBase::WeakHandleCoreBase()
  11. : owner_loop_task_runner_(base::SequencedTaskRunnerHandle::Get()) {}
  12. bool WeakHandleCoreBase::IsOnOwnerThread() const {
  13. return owner_loop_task_runner_->RunsTasksInCurrentSequence();
  14. }
  15. WeakHandleCoreBase::~WeakHandleCoreBase() = default;
  16. void WeakHandleCoreBase::PostToOwnerThread(const base::Location& from_here,
  17. base::OnceClosure fn) const {
  18. if (!owner_loop_task_runner_->PostTask(from_here, std::move(fn))) {
  19. DVLOG(1) << "Could not post task from " << from_here.ToString();
  20. }
  21. }
  22. } // namespace syncer::internal