OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/shell/dynamic_service_loader.h" | 5 #include "mojo/shell/dynamic_service_loader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 explicit LocalLoader(scoped_ptr<DynamicServiceRunner> runner) | 60 explicit LocalLoader(scoped_ptr<DynamicServiceRunner> runner) |
61 : Loader(runner.Pass()) { | 61 : Loader(runner.Pass()) { |
62 } | 62 } |
63 | 63 |
64 virtual void Start(const GURL& url, | 64 virtual void Start(const GURL& url, |
65 ScopedMessagePipeHandle service_handle, | 65 ScopedMessagePipeHandle service_handle, |
66 Context* context) OVERRIDE { | 66 Context* context) OVERRIDE { |
67 base::FilePath path; | 67 base::FilePath path; |
68 net::FileURLToFilePath(url, &path); | 68 net::FileURLToFilePath(url, &path); |
69 | 69 |
| 70 // TODO(darin): Check if the given file path exists. |
| 71 |
70 // Complete asynchronously for consistency with NetworkServiceLoader. | 72 // Complete asynchronously for consistency with NetworkServiceLoader. |
71 base::MessageLoop::current()->PostTask( | 73 base::MessageLoop::current()->PostTask( |
72 FROM_HERE, | 74 FROM_HERE, |
73 base::Bind(&Loader::StartService, | 75 base::Bind(&Loader::StartService, |
74 base::Unretained(this), | 76 base::Unretained(this), |
75 path, | 77 path, |
76 base::Passed(&service_handle), | 78 base::Passed(&service_handle), |
77 base::PathExists(path))); | 79 true)); |
78 } | 80 } |
79 }; | 81 }; |
80 | 82 |
81 // For loading services via the network stack. | 83 // For loading services via the network stack. |
82 class NetworkLoader : public Loader { | 84 class NetworkLoader : public Loader { |
83 public: | 85 public: |
84 explicit NetworkLoader(scoped_ptr<DynamicServiceRunner> runner, | 86 explicit NetworkLoader(scoped_ptr<DynamicServiceRunner> runner, |
85 NetworkService* network_service) | 87 NetworkService* network_service) |
86 : Loader(runner.Pass()) { | 88 : Loader(runner.Pass()) { |
87 network_service->CreateURLLoader(Get(&url_loader_)); | 89 network_service->CreateURLLoader(Get(&url_loader_)); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 } | 178 } |
177 | 179 |
178 void DynamicServiceLoader::OnServiceError(ServiceManager* manager, | 180 void DynamicServiceLoader::OnServiceError(ServiceManager* manager, |
179 const GURL& url) { | 181 const GURL& url) { |
180 // TODO(darin): What should we do about service errors? This implies that | 182 // TODO(darin): What should we do about service errors? This implies that |
181 // the app closed its handle to the service manager. Maybe we don't care? | 183 // the app closed its handle to the service manager. Maybe we don't care? |
182 } | 184 } |
183 | 185 |
184 } // namespace shell | 186 } // namespace shell |
185 } // namespace mojo | 187 } // namespace mojo |
OLD | NEW |