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_application_loader.h" | 5 #include "mojo/shell/dynamic_application_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/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 // Async for consistency with network case. | 109 // Async for consistency with network case. |
110 base::MessageLoop::current()->PostTask( | 110 base::MessageLoop::current()->PostTask( |
111 FROM_HERE, | 111 FROM_HERE, |
112 base::Bind(&LocalLoader::RunLibrary, | 112 base::Bind(&LocalLoader::RunLibrary, |
113 weak_ptr_factory_.GetWeakPtr(), | 113 weak_ptr_factory_.GetWeakPtr(), |
114 path, | 114 path, |
115 base::PathExists(path))); | 115 base::PathExists(path))); |
116 } | 116 } |
117 | 117 |
118 virtual ~LocalLoader() {} | 118 ~LocalLoader() override {} |
119 | 119 |
120 private: | 120 private: |
121 base::WeakPtrFactory<LocalLoader> weak_ptr_factory_; | 121 base::WeakPtrFactory<LocalLoader> weak_ptr_factory_; |
122 }; | 122 }; |
123 | 123 |
124 // A loader for network files. | 124 // A loader for network files. |
125 class DynamicApplicationLoader::NetworkLoader : public Loader { | 125 class DynamicApplicationLoader::NetworkLoader : public Loader { |
126 public: | 126 public: |
127 NetworkLoader(const GURL& url, | 127 NetworkLoader(const GURL& url, |
128 MimeTypeToURLMap* mime_type_to_url, | 128 MimeTypeToURLMap* mime_type_to_url, |
(...skipping 16 matching lines...) Expand all Loading... |
145 switches::kDisableCache)) { | 145 switches::kDisableCache)) { |
146 request->bypass_cache = true; | 146 request->bypass_cache = true; |
147 } | 147 } |
148 | 148 |
149 network_service->CreateURLLoader(GetProxy(&url_loader_)); | 149 network_service->CreateURLLoader(GetProxy(&url_loader_)); |
150 url_loader_->Start(request.Pass(), | 150 url_loader_->Start(request.Pass(), |
151 base::Bind(&NetworkLoader::OnLoadComplete, | 151 base::Bind(&NetworkLoader::OnLoadComplete, |
152 weak_ptr_factory_.GetWeakPtr())); | 152 weak_ptr_factory_.GetWeakPtr())); |
153 } | 153 } |
154 | 154 |
155 virtual ~NetworkLoader() { | 155 ~NetworkLoader() override { |
156 if (!file_.empty()) | 156 if (!file_.empty()) |
157 base::DeleteFile(file_, false); | 157 base::DeleteFile(file_, false); |
158 } | 158 } |
159 | 159 |
160 private: | 160 private: |
161 void OnLoadComplete(URLResponsePtr response) { | 161 void OnLoadComplete(URLResponsePtr response) { |
162 if (response->error) { | 162 if (response->error) { |
163 LOG(ERROR) << "Error (" << response->error->code << ": " | 163 LOG(ERROR) << "Error (" << response->error->code << ": " |
164 << response->error->description << ") while fetching " | 164 << response->error->description << ") while fetching " |
165 << response->url; | 165 << response->url; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // TODO(darin): What should we do about service errors? This implies that | 250 // TODO(darin): What should we do about service errors? This implies that |
251 // the app closed its handle to the service manager. Maybe we don't care? | 251 // the app closed its handle to the service manager. Maybe we don't care? |
252 } | 252 } |
253 | 253 |
254 void DynamicApplicationLoader::LoaderComplete(Loader* loader) { | 254 void DynamicApplicationLoader::LoaderComplete(Loader* loader) { |
255 loaders_.erase(std::find(loaders_.begin(), loaders_.end(), loader)); | 255 loaders_.erase(std::find(loaders_.begin(), loaders_.end(), loader)); |
256 } | 256 } |
257 | 257 |
258 } // namespace shell | 258 } // namespace shell |
259 } // namespace mojo | 259 } // namespace mojo |
OLD | NEW |