Add Apps.AppListSearchQueryLength UMA histogram.
[chromium-blink-merge.git] / mojo / services / network / network_service_delegate.cc
blobd608b33dd8a1884d9c29ce28cdd2a5b967ef8337
1 // Copyright 2015 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.
5 #include "mojo/services/network/network_service_delegate.h"
7 #include "base/at_exit.h"
8 #include "base/base_paths.h"
9 #include "base/files/file_path.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/path_service.h"
12 #include "third_party/mojo/src/mojo/public/cpp/application/application_connection.h"
14 NetworkServiceDelegate::NetworkServiceDelegate() {}
16 NetworkServiceDelegate::~NetworkServiceDelegate() {}
18 void NetworkServiceDelegate::Initialize(mojo::ApplicationImpl* app) {
19 base::FilePath base_path;
20 CHECK(PathService::Get(base::DIR_TEMP, &base_path));
21 base_path = base_path.Append(FILE_PATH_LITERAL("network_service"));
22 context_.reset(new mojo::NetworkContext(base_path));
25 bool NetworkServiceDelegate::ConfigureIncomingConnection(
26 mojo::ApplicationConnection* connection) {
27 DCHECK(context_);
28 connection->AddService(this);
29 return true;
32 void NetworkServiceDelegate::Quit() {
33 // Destroy the NetworkContext now as it requires MessageLoop::current() upon
34 // destruction and it is the last moment we know for sure that it is
35 // running.
36 context_.reset();
39 void NetworkServiceDelegate::Create(
40 mojo::ApplicationConnection* connection,
41 mojo::InterfaceRequest<mojo::NetworkService> request) {
42 mojo::BindToRequest(
43 new mojo::NetworkServiceImpl(connection, context_.get()), &request);