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

Side by Side Diff: components/precache/core/fetcher_pool.h

Issue 2037903002: Precache manifest should not be added to fetcher pool which is full (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 6 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 | components/precache/core/precache_fetcher.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef COMPONENTS_PRECACHE_CORE_FETCHER_POOL_H_ 5 #ifndef COMPONENTS_PRECACHE_CORE_FETCHER_POOL_H_
6 #define COMPONENTS_PRECACHE_CORE_FETCHER_POOL_H_ 6 #define COMPONENTS_PRECACHE_CORE_FETCHER_POOL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <unordered_map> 9 #include <unordered_map>
10 10
11 #include "base/gtest_prod_util.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 13
13 namespace precache { 14 namespace precache {
14 15
15 // FetcherPool that accepts a limited number of elements. 16 // FetcherPool that accepts a limited number of elements.
16 // 17 //
17 // FetcherPool is particularly suited for having multiple URLFetchers running 18 // FetcherPool is particularly suited for having multiple URLFetchers running
18 // in parallel. 19 // in parallel.
19 // 20 //
20 // It doesn't enqueue the elements above a defined capacity. The callsite must 21 // It doesn't enqueue the elements above a defined capacity. The callsite must
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // Returns true iff the pool is empty. 65 // Returns true iff the pool is empty.
65 bool IsEmpty() const { return elements_.empty(); } 66 bool IsEmpty() const { return elements_.empty(); }
66 67
67 // Returns true iff the pool can accept a new element. 68 // Returns true iff the pool can accept a new element.
68 bool IsAvailable() const { return max_size_ > elements_.size(); } 69 bool IsAvailable() const { return max_size_ > elements_.size(); }
69 70
70 const std::unordered_map<const T*, std::unique_ptr<T>>& elements() const { 71 const std::unordered_map<const T*, std::unique_ptr<T>>& elements() const {
71 return elements_; 72 return elements_;
72 } 73 }
73 74
75 // Returns the maximum size of the pool.
76 size_t max_size() const { return max_size_; }
77
74 private: 78 private:
75 const size_t max_size_; 79 const size_t max_size_;
76 std::unordered_map<const T*, std::unique_ptr<T>> elements_; 80 std::unordered_map<const T*, std::unique_ptr<T>> elements_;
77 81
78 DISALLOW_COPY_AND_ASSIGN(FetcherPool); 82 DISALLOW_COPY_AND_ASSIGN(FetcherPool);
79 }; 83 };
80 84
81 } // namespace precache 85 } // namespace precache
82 86
83 #endif // COMPONENTS_PRECACHE_CORE_FETCHER_POOL_H_ 87 #endif // COMPONENTS_PRECACHE_CORE_FETCHER_POOL_H_
OLDNEW
« no previous file with comments | « no previous file | components/precache/core/precache_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698