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

Side by Side Diff: mojo/fetcher/data_fetcher.cc

Issue 1356503003: data-fetcher: Discard really big data URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « no previous file | 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/fetcher/data_fetcher.h" 5 #include "mojo/fetcher/data_fetcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/thread_task_runner_handle.h" 12 #include "base/thread_task_runner_handle.h"
13 #include "net/base/data_url.h" 13 #include "net/base/data_url.h"
14 #include "third_party/mojo/src/mojo/public/cpp/system/data_pipe.h" 14 #include "third_party/mojo/src/mojo/public/cpp/system/data_pipe.h"
15 15
16 namespace mojo { 16 namespace mojo {
17 namespace fetcher { 17 namespace fetcher {
18 18
19 ScopedDataPipeConsumerHandle CreateConsumerHandleForString( 19 ScopedDataPipeConsumerHandle CreateConsumerHandleForString(
20 const std::string& data) { 20 const std::string& data) {
21 if (data.size() > std::numeric_limits<uint32_t>::max())
22 return ScopedDataPipeConsumerHandle();
21 uint32_t num_bytes = static_cast<uint32_t>(data.size()); 23 uint32_t num_bytes = static_cast<uint32_t>(data.size());
22 MojoCreateDataPipeOptions options; 24 MojoCreateDataPipeOptions options;
23 options.struct_size = sizeof(MojoCreateDataPipeOptions); 25 options.struct_size = sizeof(MojoCreateDataPipeOptions);
24 options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE; 26 options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE;
25 options.element_num_bytes = 1; 27 options.element_num_bytes = 1;
26 options.capacity_num_bytes = num_bytes; 28 options.capacity_num_bytes = num_bytes;
27 mojo::DataPipe data_pipe(options); 29 mojo::DataPipe data_pipe(options);
28 MojoResult result = 30 MojoResult result =
29 WriteDataRaw(data_pipe.producer_handle.get(), data.data(), &num_bytes, 31 WriteDataRaw(data_pipe.producer_handle.get(), data.data(), &num_bytes,
30 MOJO_WRITE_DATA_FLAG_ALL_OR_NONE); 32 MOJO_WRITE_DATA_FLAG_ALL_OR_NONE);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 bool DataFetcher::PeekFirstLine(std::string* line) { 106 bool DataFetcher::PeekFirstLine(std::string* line) {
105 // This is only called for 'mojo magic' (i.e. detecting shebang'ed 107 // This is only called for 'mojo magic' (i.e. detecting shebang'ed
106 // content-handler. Since HasMojoMagic() returns false above, this should 108 // content-handler. Since HasMojoMagic() returns false above, this should
107 // never be reached. 109 // never be reached.
108 NOTREACHED(); 110 NOTREACHED();
109 return false; 111 return false;
110 } 112 }
111 113
112 } // namespace fetcher 114 } // namespace fetcher
113 } // namespace mojo 115 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698