Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Unified Diff: services/shell/public/cpp/lib/shell_connection_ref.cc

Issue 2131493002: ShellConnection -> ServiceContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@st
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/shell/public/cpp/lib/shell_connection.cc ('k') | services/shell/public/cpp/service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/shell/public/cpp/lib/shell_connection_ref.cc
diff --git a/services/shell/public/cpp/lib/shell_connection_ref.cc b/services/shell/public/cpp/lib/shell_connection_ref.cc
deleted file mode 100644
index 388c028f4aee029e73560d779385f064dc51dd16..0000000000000000000000000000000000000000
--- a/services/shell/public/cpp/lib/shell_connection_ref.cc
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "services/shell/public/cpp/shell_connection_ref.h"
-
-#include "base/bind.h"
-#include "base/memory/ptr_util.h"
-#include "base/message_loop/message_loop.h"
-#include "base/threading/thread_checker.h"
-#include "base/threading/thread_task_runner_handle.h"
-
-namespace shell {
-
-class ShellConnectionRefImpl : public ShellConnectionRef {
- public:
- ShellConnectionRefImpl(
- base::WeakPtr<ShellConnectionRefFactory> factory,
- scoped_refptr<base::SingleThreadTaskRunner> service_task_runner)
- : factory_(factory),
- service_task_runner_(service_task_runner) {
- // This object is not thread-safe but may be used exclusively on a different
- // thread from the one which constructed it.
- thread_checker_.DetachFromThread();
- }
-
- ~ShellConnectionRefImpl() override {
- DCHECK(thread_checker_.CalledOnValidThread());
-
- if (service_task_runner_->BelongsToCurrentThread() && factory_) {
- factory_->Release();
- } else {
- service_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&ShellConnectionRefFactory::Release, factory_));
- }
- }
-
- private:
- // ShellConnectionRef:
- std::unique_ptr<ShellConnectionRef> Clone() override {
- DCHECK(thread_checker_.CalledOnValidThread());
-
- if (service_task_runner_->BelongsToCurrentThread() && factory_) {
- factory_->AddRef();
- } else {
- service_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&ShellConnectionRefFactory::AddRef, factory_));
- }
-
- return base::WrapUnique(
- new ShellConnectionRefImpl(factory_, service_task_runner_));
- }
-
- base::WeakPtr<ShellConnectionRefFactory> factory_;
- scoped_refptr<base::SingleThreadTaskRunner> service_task_runner_;
- base::ThreadChecker thread_checker_;
-
- DISALLOW_COPY_AND_ASSIGN(ShellConnectionRefImpl);
-};
-
-ShellConnectionRefFactory::ShellConnectionRefFactory(
- const base::Closure& quit_closure)
- : quit_closure_(quit_closure), weak_factory_(this) {
- DCHECK(!quit_closure_.is_null());
-}
-
-ShellConnectionRefFactory::~ShellConnectionRefFactory() {}
-
-std::unique_ptr<ShellConnectionRef> ShellConnectionRefFactory::CreateRef() {
- AddRef();
- return base::WrapUnique(
- new ShellConnectionRefImpl(weak_factory_.GetWeakPtr(),
- base::ThreadTaskRunnerHandle::Get()));
-}
-
-void ShellConnectionRefFactory::AddRef() {
- ++ref_count_;
-}
-
-void ShellConnectionRefFactory::Release() {
- if (!--ref_count_)
- quit_closure_.Run();
-}
-
-} // namespace shell
« no previous file with comments | « services/shell/public/cpp/lib/shell_connection.cc ('k') | services/shell/public/cpp/service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698