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

Side by Side Diff: mojo/shell/local_fetcher.cc

Issue 1129143005: Introduce Http{Request,Response} mojom structs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « mojo/services/network/url_loader_impl.cc ('k') | no next file » | 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 "mojo/shell/local_fetcher.h" 5 #include "mojo/shell/local_fetcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 47
48 URLResponsePtr LocalFetcher::AsURLResponse(base::TaskRunner* task_runner, 48 URLResponsePtr LocalFetcher::AsURLResponse(base::TaskRunner* task_runner,
49 uint32_t skip) { 49 uint32_t skip) {
50 URLResponsePtr response(URLResponse::New()); 50 URLResponsePtr response(URLResponse::New());
51 response->url = String::From(url_); 51 response->url = String::From(url_);
52 DataPipe data_pipe; 52 DataPipe data_pipe;
53 response->body = data_pipe.consumer_handle.Pass(); 53 response->body = data_pipe.consumer_handle.Pass();
54 int64 file_size; 54 int64 file_size;
55 if (base::GetFileSize(path_, &file_size)) { 55 if (base::GetFileSize(path_, &file_size)) {
56 response->headers = Array<HTTPHeaderPtr>(1); 56 response->headers = Array<HttpHeaderPtr>(1);
57 HTTPHeaderPtr header = HTTPHeader::New(); 57 HttpHeaderPtr header = HttpHeader::New();
58 header->name = "Content-Length"; 58 header->name = "Content-Length";
59 header->value = base::StringPrintf("%" PRId64, file_size); 59 header->value = base::StringPrintf("%" PRId64, file_size);
60 response->headers[0] = header.Pass(); 60 response->headers[0] = header.Pass();
61 } 61 }
62 common::CopyFromFile(path_, data_pipe.producer_handle.Pass(), skip, 62 common::CopyFromFile(path_, data_pipe.producer_handle.Pass(), skip,
63 task_runner, base::Bind(&IgnoreResult)); 63 task_runner, base::Bind(&IgnoreResult));
64 return response.Pass(); 64 return response.Pass();
65 } 65 }
66 66
67 void LocalFetcher::AsPath( 67 void LocalFetcher::AsPath(
(...skipping 19 matching lines...) Expand all
87 ReadFileToString(path_, &start_of_file, kMaxShebangLength); 87 ReadFileToString(path_, &start_of_file, kMaxShebangLength);
88 size_t return_position = start_of_file.find('\n'); 88 size_t return_position = start_of_file.find('\n');
89 if (return_position == std::string::npos) 89 if (return_position == std::string::npos)
90 return false; 90 return false;
91 *line = start_of_file.substr(0, return_position + 1); 91 *line = start_of_file.substr(0, return_position + 1);
92 return true; 92 return true;
93 } 93 }
94 94
95 } // namespace shell 95 } // namespace shell
96 } // namespace mojo 96 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/network/url_loader_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698