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
) {
28 connection
->AddService(this);
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
39 void NetworkServiceDelegate::Create(
40 mojo::ApplicationConnection
* connection
,
41 mojo::InterfaceRequest
<mojo::NetworkService
> request
) {
43 new mojo::NetworkServiceImpl(connection
, context_
.get()), &request
);