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

Side by Side Diff: extensions/browser/extension_protocols.cc

Issue 2771953003: Fix content verification code for undreadable and deleted files. (Closed)
Patch Set: address comments change DCHECK Created 3 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/extension_protocols.h" 5 #include "extensions/browser/extension_protocols.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // TODO(asargent) - we'll need to add proper support for range headers. 230 // TODO(asargent) - we'll need to add proper support for range headers.
231 // crbug.com/369895. 231 // crbug.com/369895.
232 std::string range_header; 232 std::string range_header;
233 if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) { 233 if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) {
234 if (verify_job_.get()) 234 if (verify_job_.get())
235 verify_job_ = NULL; 235 verify_job_ = NULL;
236 } 236 }
237 URLRequestFileJob::SetExtraRequestHeaders(headers); 237 URLRequestFileJob::SetExtraRequestHeaders(headers);
238 } 238 }
239 239
240 void OnOpenComplete(int result) override {
241 if (result < 0) {
242 // This can happen when the file is unreadable (which can happen during
243 // corruption or third-party interaction). We need to be sure to inform
244 // the verification job that we've finished reading so that it can
245 // proceed; see crbug.com/703888.
246 if (verify_job_.get()) {
247 std::string tmp;
248 verify_job_->BytesRead(0, base::string_as_array(&tmp));
249 verify_job_->DoneReading();
250 }
251 }
252 }
253
240 void OnSeekComplete(int64_t result) override { 254 void OnSeekComplete(int64_t result) override {
241 DCHECK_EQ(seek_position_, 0); 255 DCHECK_EQ(seek_position_, 0);
242 seek_position_ = result; 256 seek_position_ = result;
243 // TODO(asargent) - we'll need to add proper support for range headers. 257 // TODO(asargent) - we'll need to add proper support for range headers.
244 // crbug.com/369895. 258 // crbug.com/369895.
245 if (result > 0 && verify_job_.get()) 259 if (result > 0 && verify_job_.get())
246 verify_job_ = NULL; 260 verify_job_ = NULL;
247 } 261 }
248 262
249 void OnReadComplete(net::IOBuffer* buffer, int result) override { 263 void OnReadComplete(net::IOBuffer* buffer, int result) override {
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 extensions::InfoMap* extension_info_map) { 611 extensions::InfoMap* extension_info_map) {
598 return base::MakeUnique<ExtensionProtocolHandler>(is_incognito, 612 return base::MakeUnique<ExtensionProtocolHandler>(is_incognito,
599 extension_info_map); 613 extension_info_map);
600 } 614 }
601 615
602 void SetExtensionProtocolTestHandler(ExtensionProtocolTestHandler* handler) { 616 void SetExtensionProtocolTestHandler(ExtensionProtocolTestHandler* handler) {
603 g_test_handler = handler; 617 g_test_handler = handler;
604 } 618 }
605 619
606 } // namespace extensions 620 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/content_verify_job_unittest.cc ('k') | extensions/browser/scoped_ignore_content_verifier_for_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698