summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoragayev@chromium.org <agayev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-27 18:37:03 +0000
committeragayev@chromium.org <agayev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-27 18:37:03 +0000
commitb4ae444bfcf965b735181d9a9198eec26773f2fa (patch)
tree2603be60f19659b8f68dce72ddde08dd4fda0caf
parente5d35a6d5fa430bb4e70c08ff13b9b13bf3fd2c7 (diff)
downloadchromium_src-b4ae444bfcf965b735181d9a9198eec26773f2fa.zip
chromium_src-b4ae444bfcf965b735181d9a9198eec26773f2fa.tar.gz
chromium_src-b4ae444bfcf965b735181d9a9198eec26773f2fa.tar.bz2
Moved mru_cache from content/common to base/memory.
BUG=None TEST=None Review URL: http://codereview.chromium.org/6883187 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83182 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/base.gyp8
-rw-r--r--base/base.gypi1
-rw-r--r--base/memory/mru_cache.h (renamed from content/common/mru_cache.h)12
-rw-r--r--base/memory/mru_cache_unittest.cc (renamed from content/common/mru_cache_unittest.cc)14
-rw-r--r--chrome/browser/history/history_backend.h4
-rw-r--r--chrome/browser/history/text_database_manager.cc3
-rw-r--r--chrome/browser/history/text_database_manager.h6
-rw-r--r--chrome/chrome_tests.gypi8
-rw-r--r--content/browser/renderer_host/backing_store_manager.cc5
-rw-r--r--content/content_common.gypi1
10 files changed, 34 insertions, 28 deletions
diff --git a/base/base.gyp b/base/base.gyp
index d103b45..868e20e 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -139,6 +139,7 @@
'mac/objc_property_releaser_unittest.mm',
'md5_unittest.cc',
'memory/linked_ptr_unittest.cc',
+ 'memory/mru_cache_unittest.cc',
'memory/ref_counted_unittest.cc',
'memory/scoped_native_library_unittest.cc',
'memory/scoped_ptr_unittest.cc',
@@ -242,6 +243,13 @@
],
},
],
+ ['gcc_version==44', {
+ # Avoid gcc 4.4 strict aliasing issues in stl_tree.h when
+ # building mru_cache_unittest.cc.
+ 'cflags': [
+ '-fno-strict-aliasing',
+ ],
+ }],
],
'dependencies': [
'../build/linux/system.gyp:gtk',
diff --git a/base/base.gypi b/base/base.gypi
index 77678eb..fa88b3e 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -131,6 +131,7 @@
'memory/linked_ptr.h',
'memory/memory_debug.cc',
'memory/memory_debug.h',
+ 'memory/mru_cache.h',
'memory/raw_scoped_refptr_mismatch_checker.h',
'memory/ref_counted.cc',
'memory/ref_counted.h',
diff --git a/content/common/mru_cache.h b/base/memory/mru_cache.h
index 6e94b92..132b324 100644
--- a/content/common/mru_cache.h
+++ b/base/memory/mru_cache.h
@@ -13,8 +13,8 @@
// legibility rather than optimality. If future profiling identifies this as
// a bottleneck, there is room for smaller values of 1 in the O(1). :]
-#ifndef CONTENT_COMMON_MRU_CACHE_H_
-#define CONTENT_COMMON_MRU_CACHE_H_
+#ifndef BASE_MEMORY_MRU_CACHE_H_
+#define BASE_MEMORY_MRU_CACHE_H_
#pragma once
#include <list>
@@ -24,6 +24,8 @@
#include "base/basictypes.h"
#include "base/logging.h"
+namespace base {
+
// MRUCacheBase ----------------------------------------------------------------
// Base class for the MRU cache specializations defined below.
@@ -67,6 +69,8 @@ class MRUCacheBase {
i = Erase(i);
}
+ size_type max_size() const { return max_size_; }
+
// Inserts a payload item with the given key. If an existing item has
// the same key, it is removed prior to insertion. An iterator indicating the
// inserted item will be returned (this will always be the front of the list).
@@ -254,4 +258,6 @@ class OwningMRUCache
DISALLOW_COPY_AND_ASSIGN(OwningMRUCache);
};
-#endif // CONTENT_COMMON_MRU_CACHE_H_
+} // namespace base
+
+#endif // BASE_MEMORY_MRU_CACHE_H_
diff --git a/content/common/mru_cache_unittest.cc b/base/memory/mru_cache_unittest.cc
index bd18ffe..89ca2fa 100644
--- a/content/common/mru_cache_unittest.cc
+++ b/base/memory/mru_cache_unittest.cc
@@ -1,9 +1,9 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/basictypes.h"
-#include "content/common/mru_cache.h"
+#include "base/memory/mru_cache.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -33,7 +33,7 @@ struct CachedItem {
} // namespace
TEST(MRUCacheTest, Basic) {
- typedef MRUCache<int, CachedItem> Cache;
+ typedef base::MRUCache<int, CachedItem> Cache;
Cache cache(Cache::NO_AUTO_EVICT);
// Check failure conditions
@@ -113,7 +113,7 @@ TEST(MRUCacheTest, Basic) {
}
TEST(MRUCacheTest, GetVsPeek) {
- typedef MRUCache<int, CachedItem> Cache;
+ typedef base::MRUCache<int, CachedItem> Cache;
Cache cache(Cache::NO_AUTO_EVICT);
static const int kItem1Key = 1;
@@ -148,7 +148,7 @@ TEST(MRUCacheTest, GetVsPeek) {
}
TEST(MRUCacheTest, KeyReplacement) {
- typedef MRUCache<int, CachedItem> Cache;
+ typedef base::MRUCache<int, CachedItem> Cache;
Cache cache(Cache::NO_AUTO_EVICT);
static const int kItem1Key = 1;
@@ -186,7 +186,7 @@ TEST(MRUCacheTest, KeyReplacement) {
// Make sure that the owning version release its pointers properly.
TEST(MRUCacheTest, Owning) {
- typedef OwningMRUCache<int, CachedItem*> Cache;
+ typedef base::OwningMRUCache<int, CachedItem*> Cache;
Cache cache(Cache::NO_AUTO_EVICT);
int initial_count = cached_item_live_count;
@@ -229,7 +229,7 @@ TEST(MRUCacheTest, Owning) {
}
TEST(MRUCacheTest, AutoEvict) {
- typedef OwningMRUCache<int, CachedItem*> Cache;
+ typedef base::OwningMRUCache<int, CachedItem*> Cache;
static const Cache::size_type kMaxSize = 3;
int initial_count = cached_item_live_count;
diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h
index fd2f0fd..9bf8340 100644
--- a/chrome/browser/history/history_backend.h
+++ b/chrome/browser/history/history_backend.h
@@ -12,6 +12,7 @@
#include "app/sql/init_status.h"
#include "base/file_path.h"
#include "base/gtest_prod_util.h"
+#include "base/memory/mru_cache.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/history/archived_database.h"
#include "chrome/browser/history/expire_history_backend.h"
@@ -22,7 +23,6 @@
#include "chrome/browser/history/thumbnail_database.h"
#include "chrome/browser/history/visit_tracker.h"
#include "chrome/browser/search_engines/template_url_id.h"
-#include "content/common/mru_cache.h"
class BookmarkService;
struct DownloadCreateInfo;
@@ -555,7 +555,7 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
//
// As with AddPage, the last item in the redirect chain will be the
// destination of the redirect (i.e., the key into recent_redirects_);
- typedef MRUCache<GURL, history::RedirectList> RedirectCache;
+ typedef base::MRUCache<GURL, history::RedirectList> RedirectCache;
RedirectCache recent_redirects_;
// Timestamp of the last page addition request. We use this to detect when
diff --git a/chrome/browser/history/text_database_manager.cc b/chrome/browser/history/text_database_manager.cc
index e884ec1..1e20087 100644
--- a/chrome/browser/history/text_database_manager.cc
+++ b/chrome/browser/history/text_database_manager.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,7 +13,6 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/history/history_publisher.h"
#include "chrome/browser/history/visit_database.h"
-#include "content/common/mru_cache.h"
using base::Time;
using base::TimeDelta;
diff --git a/chrome/browser/history/text_database_manager.h b/chrome/browser/history/text_database_manager.h
index 952edc6..0bf541f 100644
--- a/chrome/browser/history/text_database_manager.h
+++ b/chrome/browser/history/text_database_manager.h
@@ -14,11 +14,11 @@
#include "base/gtest_prod_util.h"
#include "base/string16.h"
#include "base/task.h"
+#include "base/memory/mru_cache.h"
#include "chrome/browser/history/history_types.h"
#include "chrome/browser/history/text_database.h"
#include "chrome/browser/history/query_parser.h"
#include "chrome/browser/history/url_database.h"
-#include "content/common/mru_cache.h"
namespace history {
@@ -262,7 +262,7 @@ class TextDatabaseManager {
// using Get. Instead, we keep them in the order they were inserted, since
// this is the metric we use to measure age. The MRUCache gives us an ordered
// list with fast lookup by URL.
- typedef MRUCache<GURL, PageInfo> RecentChangeList;
+ typedef base::MRUCache<GURL, PageInfo> RecentChangeList;
RecentChangeList recent_changes_;
// Nesting levels of transactions. Since sqlite only allows one open
@@ -273,7 +273,7 @@ class TextDatabaseManager {
// The cache owns the TextDatabase pointers, they will be automagically
// deleted when the cache entry is removed or expired.
- typedef OwningMRUCache<TextDatabase::DBIdent, TextDatabase*> DBCache;
+ typedef base::OwningMRUCache<TextDatabase::DBIdent, TextDatabase*> DBCache;
DBCache db_cache_;
// Tells us about the existence of database files on disk. All existing
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index d108af5..c9fb9ae 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1907,7 +1907,6 @@
'../content/common/gpu/gpu_feature_flags_unittest.cc',
'../content/common/gpu/gpu_info_unittest.cc',
'../content/common/gpu/gpu_video_decoder_unittest.cc',
- '../content/common/mru_cache_unittest.cc',
'../content/common/notification_service_unittest.cc',
'../content/common/process_watcher_unittest.cc',
'../content/common/property_bag_unittest.cc',
@@ -1965,13 +1964,6 @@
}],
['OS=="linux"', {
'conditions': [
- ['gcc_version==44', {
- # Avoid gcc 4.4 strict aliasing issues in stl_tree.h when
- # building mru_cache_unittest.cc.
- 'cflags': [
- '-fno-strict-aliasing',
- ],
- }],
['selinux==0', {
'dependencies': [
'../sandbox/sandbox.gyp:*',
diff --git a/content/browser/renderer_host/backing_store_manager.cc b/content/browser/renderer_host/backing_store_manager.cc
index 58d6271..fd9cca7 100644
--- a/content/browser/renderer_host/backing_store_manager.cc
+++ b/content/browser/renderer_host/backing_store_manager.cc
@@ -5,12 +5,12 @@
#include "content/browser/renderer_host/backing_store_manager.h"
#include "base/command_line.h"
+#include "base/memory/mru_cache.h"
#include "base/sys_info.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "content/browser/renderer_host/backing_store.h"
#include "content/browser/renderer_host/render_widget_host.h"
-#include "content/common/mru_cache.h"
#include "content/common/notification_service.h"
namespace {
@@ -20,7 +20,8 @@ namespace {
// for small items (extension toolstrips and buttons, etc.). The idea is that
// we'll almost always try to evict from large_cache first since small_cache
// items will tend to be visible more of the time.
-typedef OwningMRUCache<RenderWidgetHost*, BackingStore*> BackingStoreCache;
+typedef base::OwningMRUCache<RenderWidgetHost*, BackingStore*>
+ BackingStoreCache;
static BackingStoreCache* large_cache = NULL;
static BackingStoreCache* small_cache = NULL;
diff --git a/content/content_common.gypi b/content/content_common.gypi
index fb41c84..b2e442e 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -138,7 +138,6 @@
'common/message_router.cc',
'common/message_router.h',
'common/mime_registry_messages.h',
- 'common/mru_cache.h',
'common/native_web_keyboard_event.h',
'common/native_web_keyboard_event_linux.cc',
'common/native_web_keyboard_event_mac.mm',