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

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

Issue 2419723002: Move services/shell to services/service_manager (Closed)
Patch Set: rebase Created 4 years, 2 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/service.cc ('k') | services/shell/public/cpp/lib/service_context_ref.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/shell/public/cpp/lib/service_context.cc
diff --git a/services/shell/public/cpp/lib/service_context.cc b/services/shell/public/cpp/lib/service_context.cc
deleted file mode 100644
index 0bd6be2c4c238237436a0c4b7e8d4a390593ec71..0000000000000000000000000000000000000000
--- a/services/shell/public/cpp/lib/service_context.cc
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright 2014 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/service_context.h"
-
-#include "base/bind.h"
-#include "base/logging.h"
-#include "base/message_loop/message_loop.h"
-#include "mojo/public/cpp/bindings/interface_ptr.h"
-#include "mojo/public/cpp/bindings/interface_request.h"
-#include "services/shell/public/cpp/capabilities.h"
-#include "services/shell/public/cpp/interface_registry.h"
-#include "services/shell/public/cpp/lib/connector_impl.h"
-#include "services/shell/public/cpp/service.h"
-
-namespace shell {
-
-////////////////////////////////////////////////////////////////////////////////
-// ServiceContext, public:
-
-ServiceContext::ServiceContext(shell::Service* service,
- mojom::ServiceRequest request,
- std::unique_ptr<Connector> connector,
- mojom::ConnectorRequest connector_request)
- : pending_connector_request_(std::move(connector_request)),
- service_(service),
- binding_(this, std::move(request)),
- connector_(std::move(connector)) {
- DCHECK(binding_.is_bound());
- binding_.set_connection_error_handler(
- base::Bind(&ServiceContext::OnConnectionError, base::Unretained(this)));
- if (!connector_) {
- connector_ = Connector::Create(&pending_connector_request_);
- } else {
- DCHECK(pending_connector_request_.is_pending());
- }
-}
-
-ServiceContext::~ServiceContext() {}
-
-void ServiceContext::SetConnectionLostClosure(const base::Closure& closure) {
- connection_lost_closure_ = closure;
- if (should_run_connection_lost_closure_ &&
- !connection_lost_closure_.is_null())
- connection_lost_closure_.Run();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ServiceContext, mojom::Service implementation:
-
-void ServiceContext::OnStart(const shell::Identity& identity,
- const OnStartCallback& callback) {
- identity_ = identity;
- if (!initialize_handler_.is_null())
- initialize_handler_.Run();
-
- callback.Run(std::move(pending_connector_request_));
-
- service_->OnStart(identity_);
-}
-
-void ServiceContext::OnConnect(
- const Identity& source,
- mojom::InterfaceProviderRequest interfaces,
- const Interfaces& allowed_interfaces,
- const Classes& allowed_classes) {
- // TODO(beng): do something with |allowed_classes|.
- std::unique_ptr<InterfaceRegistry> registry(
- new InterfaceRegistry(identity_, source, allowed_interfaces));
- registry->Bind(std::move(interfaces));
-
- if (!service_->OnConnect(source, registry.get()))
- return;
-
- // TODO(beng): it appears we never prune this list. We should, when the
- // registry's remote interface provider pipe breaks.
- incoming_connections_.push_back(std::move(registry));
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ServiceContext, private:
-
-void ServiceContext::OnConnectionError() {
- // Note that the Service doesn't technically have to quit now, it may live
- // on to service existing connections. All existing Connectors however are
- // invalid.
- should_run_connection_lost_closure_ = service_->OnStop();
- if (should_run_connection_lost_closure_ &&
- !connection_lost_closure_.is_null())
- connection_lost_closure_.Run();
- // We don't reset the connector as clients may have taken a raw pointer to it.
- // Connect() will return nullptr if they try to connect to anything.
-}
-
-} // namespace shell
« no previous file with comments | « services/shell/public/cpp/lib/service.cc ('k') | services/shell/public/cpp/lib/service_context_ref.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698