Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #include "content/utility/utility_process_control_impl.h" | |
| 6 | |
| 7 #include "base/memory/scoped_ptr.h" | |
| 8 #include "base/stl_util.h" | |
| 9 #include "content/public/utility/utility_thread.h" | |
| 10 #include "mojo/application/public/cpp/application_delegate.h" | |
| 11 #include "mojo/shell/static_application_loader.h" | |
| 12 | |
| 13 namespace content { | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 // Called when a static application terminates. | |
| 18 void QuitProcess() { | |
| 19 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); | |
|
jam
2015/05/29 01:48:54
nit: no "content::"
Ken Rockot(use gerrit already)
2015/05/29 03:20:40
Done.
| |
| 20 } | |
| 21 | |
| 22 } // namespace | |
| 23 | |
| 24 UtilityProcessControlImpl::UtilityProcessControlImpl() { | |
| 25 } | |
| 26 | |
| 27 UtilityProcessControlImpl::~UtilityProcessControlImpl() { | |
| 28 STLDeleteValues(&url_to_loader_map_); | |
| 29 } | |
| 30 | |
| 31 void UtilityProcessControlImpl::LoadApplication( | |
| 32 const mojo::String& url, | |
| 33 mojo::InterfaceRequest<mojo::Application> request, | |
| 34 const LoadApplicationCallback& callback) { | |
| 35 GURL application_url = GURL(url.To<std::string>()); | |
| 36 auto it = url_to_loader_map_.find(application_url); | |
| 37 if (it == url_to_loader_map_.end()) { | |
| 38 callback.Run(LOAD_APPLICATION_RESULT_NOT_FOUND); | |
| 39 return; | |
| 40 } | |
| 41 | |
| 42 callback.Run(LOAD_APPLICATION_RESULT_OK); | |
| 43 it->second->Load(application_url, request.Pass()); | |
| 44 } | |
| 45 | |
| 46 void UtilityProcessControlImpl::RegisterStaticAppForURL( | |
| 47 const GURL& url, | |
| 48 const StaticAppFactory& factory) { | |
| 49 auto result = url_to_loader_map_.insert( | |
| 50 std::make_pair(url, | |
| 51 // Cleaned up in ~UtilityProcessControlImpl. | |
| 52 new mojo::shell::StaticApplicationLoader( | |
| 53 factory, base::Bind(&QuitProcess)))); | |
| 54 DCHECK(result.second); | |
| 55 } | |
| 56 | |
| 57 } // namespace content | |
| OLD | NEW |