OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/downloads/downloads_api.h" | 5 #include "chrome/browser/extensions/api/downloads/downloads_api.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 function, | 469 function, |
470 DOWNLOADS_FUNCTION_LAST); | 470 DOWNLOADS_FUNCTION_LAST); |
471 } | 471 } |
472 | 472 |
473 void CompileDownloadQueryOrderBy( | 473 void CompileDownloadQueryOrderBy( |
474 const std::vector<std::string>& order_by_strs, | 474 const std::vector<std::string>& order_by_strs, |
475 std::string* error, | 475 std::string* error, |
476 DownloadQuery* query) { | 476 DownloadQuery* query) { |
477 // TODO(benjhayden): Consider switching from LazyInstance to explicit string | 477 // TODO(benjhayden): Consider switching from LazyInstance to explicit string |
478 // comparisons. | 478 // comparisons. |
479 static base::LazyInstance<SortTypeMap> sorter_types = | 479 static base::LazyInstance<SortTypeMap>::DestructorAtExit sorter_types = |
480 LAZY_INSTANCE_INITIALIZER; | 480 LAZY_INSTANCE_INITIALIZER; |
481 if (sorter_types.Get().empty()) | 481 if (sorter_types.Get().empty()) |
482 InitSortTypeMap(sorter_types.Pointer()); | 482 InitSortTypeMap(sorter_types.Pointer()); |
483 | 483 |
484 for (std::vector<std::string>::const_iterator iter = order_by_strs.begin(); | 484 for (std::vector<std::string>::const_iterator iter = order_by_strs.begin(); |
485 iter != order_by_strs.end(); ++iter) { | 485 iter != order_by_strs.end(); ++iter) { |
486 std::string term_str = *iter; | 486 std::string term_str = *iter; |
487 if (term_str.empty()) | 487 if (term_str.empty()) |
488 continue; | 488 continue; |
489 DownloadQuery::SortDirection direction = DownloadQuery::ASCENDING; | 489 DownloadQuery::SortDirection direction = DownloadQuery::ASCENDING; |
490 if (term_str[0] == '-') { | 490 if (term_str[0] == '-') { |
(...skipping 11 matching lines...) Expand all Loading... |
502 } | 502 } |
503 | 503 |
504 void RunDownloadQuery( | 504 void RunDownloadQuery( |
505 const downloads::DownloadQuery& query_in, | 505 const downloads::DownloadQuery& query_in, |
506 DownloadManager* manager, | 506 DownloadManager* manager, |
507 DownloadManager* incognito_manager, | 507 DownloadManager* incognito_manager, |
508 std::string* error, | 508 std::string* error, |
509 DownloadQuery::DownloadVector* results) { | 509 DownloadQuery::DownloadVector* results) { |
510 // TODO(benjhayden): Consider switching from LazyInstance to explicit string | 510 // TODO(benjhayden): Consider switching from LazyInstance to explicit string |
511 // comparisons. | 511 // comparisons. |
512 static base::LazyInstance<FilterTypeMap> filter_types = | 512 static base::LazyInstance<FilterTypeMap>::DestructorAtExit filter_types = |
513 LAZY_INSTANCE_INITIALIZER; | 513 LAZY_INSTANCE_INITIALIZER; |
514 if (filter_types.Get().empty()) | 514 if (filter_types.Get().empty()) |
515 InitFilterTypeMap(filter_types.Pointer()); | 515 InitFilterTypeMap(filter_types.Pointer()); |
516 | 516 |
517 DownloadQuery query_out; | 517 DownloadQuery query_out; |
518 | 518 |
519 size_t limit = 1000; | 519 size_t limit = 1000; |
520 if (query_in.limit.get()) { | 520 if (query_in.limit.get()) { |
521 if (*query_in.limit < 0) { | 521 if (*query_in.limit < 0) { |
522 *error = errors::kInvalidQueryLimit; | 522 *error = errors::kInvalidQueryLimit; |
523 return; | 523 return; |
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1920 return; | 1920 return; |
1921 base::Time now(base::Time::Now()); | 1921 base::Time now(base::Time::Now()); |
1922 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); | 1922 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); |
1923 if (delta <= kFileExistenceRateLimitSeconds) | 1923 if (delta <= kFileExistenceRateLimitSeconds) |
1924 return; | 1924 return; |
1925 last_checked_removal_ = now; | 1925 last_checked_removal_ = now; |
1926 manager->CheckForHistoryFilesRemoval(); | 1926 manager->CheckForHistoryFilesRemoval(); |
1927 } | 1927 } |
1928 | 1928 |
1929 } // namespace extensions | 1929 } // namespace extensions |
OLD | NEW |