OLD | NEW |
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" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 request->auto_follow_redirects = false; | 56 request->auto_follow_redirects = false; |
57 if (disable_cache) | 57 if (disable_cache) |
58 request->cache_mode = mojo::URLRequest::URLRequest::CacheMode::BYPASS_CACHE; | 58 request->cache_mode = mojo::URLRequest::URLRequest::CacheMode::BYPASS_CACHE; |
59 auto architecture_header = mojo::HttpHeader::New(); | 59 auto architecture_header = mojo::HttpHeader::New(); |
60 architecture_header->name = "X-Architecture"; | 60 architecture_header->name = "X-Architecture"; |
61 architecture_header->value = kArchitecture; | 61 architecture_header->value = kArchitecture; |
62 mojo::Array<mojo::HttpHeaderPtr> headers; | 62 mojo::Array<mojo::HttpHeaderPtr> headers; |
63 headers.push_back(architecture_header.Pass()); | 63 headers.push_back(architecture_header.Pass()); |
64 request->headers = headers.Pass(); | 64 request->headers = headers.Pass(); |
65 | 65 |
66 return request.Pass(); | 66 return request; |
67 } | 67 } |
68 | 68 |
69 // Clone an URLResponse, except for the body. | 69 // Clone an URLResponse, except for the body. |
70 mojo::URLResponsePtr CloneResponse(const mojo::URLResponsePtr& response) { | 70 mojo::URLResponsePtr CloneResponse(const mojo::URLResponsePtr& response) { |
71 mojo::URLResponsePtr cloned = mojo::URLResponse::New(); | 71 mojo::URLResponsePtr cloned = mojo::URLResponse::New(); |
72 cloned->error = response->error.Clone(); | 72 cloned->error = response->error.Clone(); |
73 cloned->url = response->url; | 73 cloned->url = response->url; |
74 cloned->status_code = response->status_code; | 74 cloned->status_code = response->status_code; |
75 cloned->status_line = response->status_line; | 75 cloned->status_line = response->status_line; |
76 cloned->headers = response->headers.Clone(); | 76 cloned->headers = response->headers.Clone(); |
77 cloned->mime_type = response->mime_type; | 77 cloned->mime_type = response->mime_type; |
78 cloned->charset = response->charset; | 78 cloned->charset = response->charset; |
79 cloned->redirect_method = response->redirect_method; | 79 cloned->redirect_method = response->redirect_method; |
80 cloned->redirect_url = response->redirect_url; | 80 cloned->redirect_url = response->redirect_url; |
81 cloned->redirect_referrer = response->redirect_referrer; | 81 cloned->redirect_referrer = response->redirect_referrer; |
82 return cloned.Pass(); | 82 return cloned; |
83 } | 83 } |
84 | 84 |
85 // This class is self owned and will delete itself after having tried to update | 85 // This class is self owned and will delete itself after having tried to update |
86 // the application cache. | 86 // the application cache. |
87 class ApplicationUpdater : public base::MessageLoop::DestructionObserver { | 87 class ApplicationUpdater : public base::MessageLoop::DestructionObserver { |
88 public: | 88 public: |
89 ApplicationUpdater(const GURL& url, | 89 ApplicationUpdater(const GURL& url, |
90 const base::TimeDelta& update_delay, | 90 const base::TimeDelta& update_delay, |
91 mojo::URLResponseDiskCache* url_response_disk_cache, | 91 mojo::URLResponseDiskCache* url_response_disk_cache, |
92 mojo::NetworkService* network_service); | 92 mojo::NetworkService* network_service); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 base::StringPrintf("%s %s\n", path.value().c_str(), url.spec().c_str()); | 332 base::StringPrintf("%s %s\n", path.value().c_str(), url.spec().c_str()); |
333 // TODO(eseidel): AppendToFile is missing O_CREAT, crbug.com/450696 | 333 // TODO(eseidel): AppendToFile is missing O_CREAT, crbug.com/450696 |
334 if (!PathExists(map_path)) { | 334 if (!PathExists(map_path)) { |
335 base::WriteFile(map_path, map_entry.data(), map_entry.length()); | 335 base::WriteFile(map_path, map_entry.data(), map_entry.length()); |
336 } else { | 336 } else { |
337 base::AppendToFile(map_path, map_entry.data(), map_entry.length()); | 337 base::AppendToFile(map_path, map_entry.data(), map_entry.length()); |
338 } | 338 } |
339 } | 339 } |
340 | 340 |
341 } // namespace shell | 341 } // namespace shell |
OLD | NEW |