OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef CHROME_RENDERER_INSTANT_RESTRICTED_ID_CACHE_H_ | 5 #ifndef CHROME_RENDERER_INSTANT_RESTRICTED_ID_CACHE_H_ |
6 #define CHROME_RENDERER_INSTANT_RESTRICTED_ID_CACHE_H_ | 6 #define CHROME_RENDERER_INSTANT_RESTRICTED_ID_CACHE_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 |
8 #include <set> | 10 #include <set> |
9 #include <utility> | 11 #include <utility> |
10 #include <vector> | 12 #include <vector> |
11 | 13 |
12 #include "base/containers/mru_cache.h" | 14 #include "base/containers/mru_cache.h" |
13 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
14 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/macros.h" |
15 #include "chrome/common/instant_types.h" | 18 #include "chrome/common/instant_types.h" |
16 | 19 |
17 // In InstantExtended, iframes are used to display objects which can only be | 20 // In InstantExtended, iframes are used to display objects which can only be |
18 // referenced by the Instant page using an ID (restricted ID). These IDs need to | 21 // referenced by the Instant page using an ID (restricted ID). These IDs need to |
19 // be unique and cached for a while so that the SearchBox API can fetch the | 22 // be unique and cached for a while so that the SearchBox API can fetch the |
20 // object info based on the ID when required by the Instant page. The reason to | 23 // object info based on the ID when required by the Instant page. The reason to |
21 // use a cache of N items as against just the last set of results is that there | 24 // use a cache of N items as against just the last set of results is that there |
22 // may be race conditions - e.g. the user clicks on a result being shown but the | 25 // may be race conditions - e.g. the user clicks on a result being shown but the |
23 // result set has internally changed but not yet been displayed. | 26 // result set has internally changed but not yet been displayed. |
24 // | 27 // |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 DCHECK(item); | 159 DCHECK(item); |
157 | 160 |
158 typename CacheImpl::const_iterator cache_it = cache_.Peek(restricted_id); | 161 typename CacheImpl::const_iterator cache_it = cache_.Peek(restricted_id); |
159 if (cache_it == cache_.end()) | 162 if (cache_it == cache_.end()) |
160 return false; | 163 return false; |
161 *item = cache_it->second; | 164 *item = cache_it->second; |
162 return true; | 165 return true; |
163 } | 166 } |
164 | 167 |
165 #endif // CHROME_RENDERER_INSTANT_RESTRICTED_ID_CACHE_H_ | 168 #endif // CHROME_RENDERER_INSTANT_RESTRICTED_ID_CACHE_H_ |
OLD | NEW |