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 "mojo/fetcher/update_fetcher.h" | 5 #include "mojo/fetcher/update_fetcher.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <utility> | 10 #include <utility> |
8 | 11 |
9 #include "base/bind.h" | 12 #include "base/bind.h" |
10 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
11 #include "base/format_macros.h" | 14 #include "base/format_macros.h" |
12 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
13 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
14 #include "mojo/common/common_type_converters.h" | 17 #include "mojo/common/common_type_converters.h" |
15 #include "mojo/common/data_pipe_utils.h" | 18 #include "mojo/common/data_pipe_utils.h" |
16 #include "mojo/common/url_type_converters.h" | 19 #include "mojo/common/url_type_converters.h" |
(...skipping 29 matching lines...) Expand all Loading... |
46 | 49 |
47 GURL UpdateFetcher::GetRedirectReferer() const { | 50 GURL UpdateFetcher::GetRedirectReferer() const { |
48 return GURL::EmptyGURL(); | 51 return GURL::EmptyGURL(); |
49 } | 52 } |
50 URLResponsePtr UpdateFetcher::AsURLResponse(base::TaskRunner* task_runner, | 53 URLResponsePtr UpdateFetcher::AsURLResponse(base::TaskRunner* task_runner, |
51 uint32_t skip) { | 54 uint32_t skip) { |
52 URLResponsePtr response(URLResponse::New()); | 55 URLResponsePtr response(URLResponse::New()); |
53 response->url = String::From(url_); | 56 response->url = String::From(url_); |
54 DataPipe data_pipe; | 57 DataPipe data_pipe; |
55 response->body = std::move(data_pipe.consumer_handle); | 58 response->body = std::move(data_pipe.consumer_handle); |
56 int64 file_size; | 59 int64_t file_size; |
57 if (base::GetFileSize(path_, &file_size)) { | 60 if (base::GetFileSize(path_, &file_size)) { |
58 response->headers = Array<HttpHeaderPtr>(1); | 61 response->headers = Array<HttpHeaderPtr>(1); |
59 HttpHeaderPtr header = HttpHeader::New(); | 62 HttpHeaderPtr header = HttpHeader::New(); |
60 header->name = "Content-Length"; | 63 header->name = "Content-Length"; |
61 header->value = base::StringPrintf("%" PRId64, file_size); | 64 header->value = base::StringPrintf("%" PRId64, file_size); |
62 response->headers[0] = std::move(header); | 65 response->headers[0] = std::move(header); |
63 } | 66 } |
64 common::CopyFromFile(path_, std::move(data_pipe.producer_handle), skip, | 67 common::CopyFromFile(path_, std::move(data_pipe.producer_handle), skip, |
65 task_runner, base::Bind(&IgnoreResult)); | 68 task_runner, base::Bind(&IgnoreResult)); |
66 return response; | 69 return response; |
(...skipping 26 matching lines...) Expand all Loading... |
93 return true; | 96 return true; |
94 } | 97 } |
95 | 98 |
96 void UpdateFetcher::OnGetAppPath(const mojo::String& path) { | 99 void UpdateFetcher::OnGetAppPath(const mojo::String& path) { |
97 path_ = base::FilePath::FromUTF8Unsafe(path); | 100 path_ = base::FilePath::FromUTF8Unsafe(path); |
98 loader_callback_.Run(make_scoped_ptr(this)); | 101 loader_callback_.Run(make_scoped_ptr(this)); |
99 } | 102 } |
100 | 103 |
101 } // namespace fetcher | 104 } // namespace fetcher |
102 } // namespace mojo | 105 } // namespace mojo |
OLD | NEW |