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

Side by Side Diff: services/url_response_disk_cache/url_response_disk_cache_impl.cc

Issue 1459033002: Replace (most) occurrences of mojo::Array<T>() with nullptr. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 | « services/files/file_impl_unittest.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 "services/url_response_disk_cache/url_response_disk_cache_impl.h" 5 #include "services/url_response_disk_cache/url_response_disk_cache_impl.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 const base::FilePath& trash_dir) { 74 const base::FilePath& trash_dir) {
75 // Delete the trash directory. 75 // Delete the trash directory.
76 task_runner->PostDelayedTask( 76 task_runner->PostDelayedTask(
77 FROM_HERE, 77 FROM_HERE,
78 base::Bind(base::IgnoreResult(&base::DeleteFile), trash_dir, true), 78 base::Bind(base::IgnoreResult(&base::DeleteFile), trash_dir, true),
79 base::TimeDelta::FromSeconds(kTrashDelayInSeconds)); 79 base::TimeDelta::FromSeconds(kTrashDelayInSeconds));
80 } 80 }
81 81
82 Array<uint8_t> PathToArray(const base::FilePath& path) { 82 Array<uint8_t> PathToArray(const base::FilePath& path) {
83 if (path.empty()) 83 if (path.empty())
84 return Array<uint8_t>(); 84 return nullptr;
85 const std::string& string = path.value(); 85 const std::string& string = path.value();
86 auto result = Array<uint8_t>::New(string.size()); 86 auto result = Array<uint8_t>::New(string.size());
87 memcpy(&result.front(), string.data(), string.size()); 87 memcpy(&result.front(), string.data(), string.size());
88 return result; 88 return result;
89 } 89 }
90 90
91 // This method remove the query string of an url if one is present. It does 91 // This method remove the query string of an url if one is present. It does
92 // match the behavior of the application manager, which connects to the same app 92 // match the behavior of the application manager, which connects to the same app
93 // if requested twice with different query parameters. 93 // if requested twice with different query parameters.
94 std::string CanonicalizeURL(const std::string& url) { 94 std::string CanonicalizeURL(const std::string& url) {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 task_runner_, canonilized_url, staged_response_body_path, 380 task_runner_, canonilized_url, staged_response_body_path,
381 base::Bind( 381 base::Bind(
382 RunCallbackWithSuccess, 382 RunCallbackWithSuccess,
383 base::Bind(&RunMojoCallbackWithResponse, callback, canonilized_url), 383 base::Bind(&RunMojoCallbackWithResponse, callback, canonilized_url),
384 identifier, request_origin_, canonilized_url, 384 identifier, request_origin_, canonilized_url,
385 base::Passed(GetMinimalResponse(canonilized_url)), db_, 385 base::Passed(GetMinimalResponse(canonilized_url)), db_,
386 task_runner_)); 386 task_runner_));
387 return; 387 return;
388 } 388 }
389 if (IsInvalidated(entry) || !IsCacheEntryValid(entry)) { 389 if (IsInvalidated(entry) || !IsCacheEntryValid(entry)) {
390 callback.Run(URLResponsePtr(), Array<uint8_t>(), Array<uint8_t>()); 390 callback.Run(URLResponsePtr(), nullptr, nullptr);
391 return; 391 return;
392 } 392 }
393 callback.Run(entry->response.Pass(), 393 callback.Run(entry->response.Pass(),
394 PathToArray(base::FilePath(entry->response_body_path)), 394 PathToArray(base::FilePath(entry->response_body_path)),
395 PathToArray(GetConsumerCacheDirectory( 395 PathToArray(GetConsumerCacheDirectory(
396 base::FilePath(entry->entry_directory)))); 396 base::FilePath(entry->entry_directory))));
397 UpdateLastInvalidation(db_, key.Pass(), base::Time::Now()); 397 UpdateLastInvalidation(db_, key.Pass(), base::Time::Now());
398 } 398 }
399 399
400 void URLResponseDiskCacheImpl::Validate(const String& url) { 400 void URLResponseDiskCacheImpl::Validate(const String& url) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 return; 515 return;
516 } 516 }
517 } 517 }
518 // We can ignore write error, as it will just force to clear the cache on the 518 // We can ignore write error, as it will just force to clear the cache on the
519 // next request. 519 // next request.
520 WriteFile(GetExtractionSentinel(entry_directory), nullptr, 0); 520 WriteFile(GetExtractionSentinel(entry_directory), nullptr, 0);
521 callback.Run(extraction_directory, consumer_cache_directory); 521 callback.Run(extraction_directory, consumer_cache_directory);
522 } 522 }
523 523
524 } // namespace mojo 524 } // namespace mojo
OLDNEW
« no previous file with comments | « services/files/file_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698