Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: shell/application_manager/network_fetcher.cc

Issue 1131953006: Shell: switches cleanup. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: gn android fix Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « shell/application_manager/network_fetcher.h ('k') | shell/child_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "shell/application_manager/network_fetcher.h" 5 #include "shell/application_manager/network_fetcher.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.h" 9 #include "base/files/file.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/process/process.h" 13 #include "base/process/process.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
19 #include "crypto/secure_hash.h" 19 #include "crypto/secure_hash.h"
20 #include "crypto/sha2.h" 20 #include "crypto/sha2.h"
21 #include "mojo/common/common_type_converters.h" 21 #include "mojo/common/common_type_converters.h"
22 #include "mojo/common/data_pipe_utils.h" 22 #include "mojo/common/data_pipe_utils.h"
23 #include "mojo/services/network/public/interfaces/network_service.mojom.h" 23 #include "mojo/services/network/public/interfaces/network_service.mojom.h"
24 #include "shell/application_manager/data_pipe_peek.h" 24 #include "shell/application_manager/data_pipe_peek.h"
25 #include "shell/switches.h"
26 25
27 namespace shell { 26 namespace shell {
28 27
29 NetworkFetcher::NetworkFetcher( 28 NetworkFetcher::NetworkFetcher(
30 bool disable_cache, 29 bool disable_cache,
30 bool predictable_app_filenames,
31 const GURL& url, 31 const GURL& url,
32 mojo::NetworkService* network_service, 32 mojo::NetworkService* network_service,
33 mojo::URLResponseDiskCache* url_response_disk_cache, 33 mojo::URLResponseDiskCache* url_response_disk_cache,
34 const FetchCallback& loader_callback) 34 const FetchCallback& loader_callback)
35 : Fetcher(loader_callback), 35 : Fetcher(loader_callback),
36 disable_cache_(false), 36 disable_cache_(disable_cache),
37 predictable_app_filenames_(predictable_app_filenames),
37 url_(url), 38 url_(url),
38 url_response_disk_cache_(url_response_disk_cache), 39 url_response_disk_cache_(url_response_disk_cache),
39 weak_ptr_factory_(this) { 40 weak_ptr_factory_(this) {
40 StartNetworkRequest(url, network_service); 41 StartNetworkRequest(url, network_service);
41 } 42 }
42 43
43 NetworkFetcher::~NetworkFetcher() { 44 NetworkFetcher::~NetworkFetcher() {
44 } 45 }
45 46
46 const GURL& NetworkFetcher::GetURL() const { 47 const GURL& NetworkFetcher::GetURL() const {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 153 }
153 154
154 void NetworkFetcher::OnFileRetrievedFromCache( 155 void NetworkFetcher::OnFileRetrievedFromCache(
155 base::Callback<void(const base::FilePath&, bool)> callback, 156 base::Callback<void(const base::FilePath&, bool)> callback,
156 mojo::Array<uint8_t> path_as_array, 157 mojo::Array<uint8_t> path_as_array,
157 mojo::Array<uint8_t> cache_dir) { 158 mojo::Array<uint8_t> cache_dir) {
158 bool success = !path_as_array.is_null(); 159 bool success = !path_as_array.is_null();
159 if (success) { 160 if (success) {
160 path_ = base::FilePath(std::string( 161 path_ = base::FilePath(std::string(
161 reinterpret_cast<char*>(&path_as_array.front()), path_as_array.size())); 162 reinterpret_cast<char*>(&path_as_array.front()), path_as_array.size()));
162 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 163 if (predictable_app_filenames_) {
163 switches::kPredictableAppFilenames)) {
164 // The copy completed, now move to $TMP/$APP_ID.mojo before the dlopen. 164 // The copy completed, now move to $TMP/$APP_ID.mojo before the dlopen.
165 base::FilePath new_path; 165 base::FilePath new_path;
166 if (RenameToAppId(url_, path_, &new_path)) { 166 if (RenameToAppId(url_, path_, &new_path)) {
167 if (base::PathExists(new_path)) { 167 if (base::PathExists(new_path)) {
168 path_ = new_path; 168 path_ = new_path;
169 success = true; 169 success = true;
170 } 170 }
171 } 171 }
172 } 172 }
173 } 173 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 << "while fetching " << response->url; 239 << "while fetching " << response->url;
240 loader_callback_.Run(nullptr); 240 loader_callback_.Run(nullptr);
241 return; 241 return;
242 } 242 }
243 243
244 response_ = response.Pass(); 244 response_ = response.Pass();
245 loader_callback_.Run(owner.Pass()); 245 loader_callback_.Run(owner.Pass());
246 } 246 }
247 247
248 } // namespace shell 248 } // namespace shell
OLDNEW
« no previous file with comments | « shell/application_manager/network_fetcher.h ('k') | shell/child_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698