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

Side by Side Diff: net/disk_cache/simple/simple_backend_impl.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 | « net/disk_cache/blockfile/backend_impl_v3.cc ('k') | net/dns/host_resolver_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "net/disk_cache/simple/simple_backend_impl.h" 5 #include "net/disk_cache/simple/simple_backend_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdlib> 8 #include <cstdlib>
9 #include <functional> 9 #include <functional>
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 using base::Time; 43 using base::Time;
44 using base::DirectoryExists; 44 using base::DirectoryExists;
45 using base::CreateDirectory; 45 using base::CreateDirectory;
46 46
47 namespace disk_cache { 47 namespace disk_cache {
48 48
49 namespace { 49 namespace {
50 50
51 // Maximum number of concurrent worker pool threads, which also is the limit 51 // Maximum number of concurrent worker pool threads, which also is the limit
52 // on concurrent IO (as we use one thread per IO request). 52 // on concurrent IO (as we use one thread per IO request).
53 const int kDefaultMaxWorkerThreads = 50; 53 const size_t kMaxWorkerThreads = 5U;
54 54
55 const char kThreadNamePrefix[] = "SimpleCache"; 55 const char kThreadNamePrefix[] = "SimpleCache";
56 56
57 // Maximum fraction of the cache that one entry can consume. 57 // Maximum fraction of the cache that one entry can consume.
58 const int kMaxFileRatio = 8; 58 const int kMaxFileRatio = 8;
59 59
60 // A global sequenced worker pool to use for launching all tasks. 60 // A global sequenced worker pool to use for launching all tasks.
61 SequencedWorkerPool* g_sequenced_worker_pool = NULL; 61 SequencedWorkerPool* g_sequenced_worker_pool = NULL;
62 62
63 void MaybeCreateSequencedWorkerPool() { 63 void MaybeCreateSequencedWorkerPool() {
64 if (!g_sequenced_worker_pool) { 64 if (!g_sequenced_worker_pool) {
65 int max_worker_threads = kDefaultMaxWorkerThreads; 65 g_sequenced_worker_pool =
66 66 new SequencedWorkerPool(kMaxWorkerThreads, kThreadNamePrefix);
67 const std::string thread_count_field_trial =
68 base::FieldTrialList::FindFullName("SimpleCacheMaxThreads");
69 if (!thread_count_field_trial.empty()) {
70 max_worker_threads =
71 std::max(1, std::atoi(thread_count_field_trial.c_str()));
72 }
73
74 g_sequenced_worker_pool = new SequencedWorkerPool(max_worker_threads,
75 kThreadNamePrefix);
76 g_sequenced_worker_pool->AddRef(); // Leak it. 67 g_sequenced_worker_pool->AddRef(); // Leak it.
77 } 68 }
78 } 69 }
79 70
80 bool g_fd_limit_histogram_has_been_populated = false; 71 bool g_fd_limit_histogram_has_been_populated = false;
81 72
82 void MaybeHistogramFdLimit(net::CacheType cache_type) { 73 void MaybeHistogramFdLimit(net::CacheType cache_type) {
83 if (g_fd_limit_histogram_has_been_populated) 74 if (g_fd_limit_histogram_has_been_populated)
84 return; 75 return;
85 76
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 this)); 723 this));
733 callback.Run(result); 724 callback.Run(result);
734 } 725 }
735 726
736 void SimpleBackendImpl::FlushWorkerPoolForTesting() { 727 void SimpleBackendImpl::FlushWorkerPoolForTesting() {
737 if (g_sequenced_worker_pool) 728 if (g_sequenced_worker_pool)
738 g_sequenced_worker_pool->FlushForTesting(); 729 g_sequenced_worker_pool->FlushForTesting();
739 } 730 }
740 731
741 } // namespace disk_cache 732 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/backend_impl_v3.cc ('k') | net/dns/host_resolver_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698