diff options
author | simon.hong81@gmail.com <simon.hong81@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-20 09:51:31 +0000 |
---|---|---|
committer | simon.hong81@gmail.com <simon.hong81@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-20 09:51:31 +0000 |
commit | ebbccb958d7979daaaac0230e6d4e785829be173 (patch) | |
tree | e95d888f26a8a649c773fc16bbbc8d5e0adf0463 | |
parent | c149b9198168ca08da0a30d4fb63f0eb232d6001 (diff) | |
download | chromium_src-ebbccb958d7979daaaac0230e6d4e785829be173.zip chromium_src-ebbccb958d7979daaaac0230e6d4e785829be173.tar.gz chromium_src-ebbccb958d7979daaaac0230e6d4e785829be173.tar.bz2 |
Move RefCountedBytes Class to base namespace.
BUG=none
TEST=compiles and tests pass on trybots
Review URL: http://codereview.chromium.org/10083022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133170 0039d316-1c4b-4281-b951-d872f2087c98
44 files changed, 163 insertions, 142 deletions
diff --git a/base/memory/ref_counted_memory.cc b/base/memory/ref_counted_memory.cc index 7e034f9..a90d5c9 100644 --- a/base/memory/ref_counted_memory.cc +++ b/base/memory/ref_counted_memory.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -20,6 +20,8 @@ size_t RefCountedStaticMemory::size() const { return length_; } +namespace base { + RefCountedBytes::RefCountedBytes() { } @@ -47,8 +49,6 @@ size_t RefCountedBytes::size() const { RefCountedBytes::~RefCountedBytes() { } -namespace base { - RefCountedString::RefCountedString() {} RefCountedString::~RefCountedString() {} diff --git a/base/memory/ref_counted_memory.h b/base/memory/ref_counted_memory.h index 7b55d14..6e6a407 100644 --- a/base/memory/ref_counted_memory.h +++ b/base/memory/ref_counted_memory.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -55,6 +55,8 @@ class BASE_EXPORT RefCountedStaticMemory : public RefCountedMemory { DISALLOW_COPY_AND_ASSIGN(RefCountedStaticMemory); }; +namespace base { + // An implementation of RefCountedMemory, where we own our the data in a // vector. class BASE_EXPORT RefCountedBytes : public RefCountedMemory { @@ -85,8 +87,6 @@ class BASE_EXPORT RefCountedBytes : public RefCountedMemory { DISALLOW_COPY_AND_ASSIGN(RefCountedBytes); }; -namespace base { - // An implementation of RefCountedMemory, where the bytes are stored in an STL // string. Use this if your data naturally arrives in that format. class BASE_EXPORT RefCountedString : public RefCountedMemory { diff --git a/chrome/browser/extensions/extension_web_ui.cc b/chrome/browser/extensions/extension_web_ui.cc index 613cb5c..0a7951d 100644 --- a/chrome/browser/extensions/extension_web_ui.cc +++ b/chrome/browser/extensions/extension_web_ui.cc @@ -97,7 +97,7 @@ class ExtensionWebUIImageLoadingTracker : public ImageLoadingTracker::Observer { &image_data)) { NOTREACHED() << "Could not encode extension favicon"; } - ForwardResult(RefCountedBytes::TakeVector(&image_data)); + ForwardResult(base::RefCountedBytes::TakeVector(&image_data)); } else { ForwardResult(NULL); } diff --git a/chrome/browser/favicon/favicon_handler_unittest.cc b/chrome/browser/favicon/favicon_handler_unittest.cc index f06312f..bdfdcbb 100644 --- a/chrome/browser/favicon/favicon_handler_unittest.cc +++ b/chrome/browser/favicon/favicon_handler_unittest.cc @@ -328,7 +328,7 @@ TEST_F(FaviconHandlerTest, GetFaviconFromHistory) { history_handler->favicon_data_.icon_type = history::FAVICON; history_handler->favicon_data_.expired = false; history_handler->favicon_data_.icon_url = icon_url; - scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); + scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data()); history_handler->favicon_data_.image_data = data; @@ -445,7 +445,7 @@ TEST_F(FaviconHandlerTest, UpdateAndDownloadFavicon) { history_handler->favicon_data_.icon_type = history::FAVICON; history_handler->favicon_data_.expired = false; history_handler->favicon_data_.icon_url = icon_url; - scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); + scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data()); history_handler->favicon_data_.image_data = data; @@ -535,7 +535,7 @@ TEST_F(FaviconHandlerTest, UpdateFavicon) { history_handler->favicon_data_.icon_type = history::FAVICON; history_handler->favicon_data_.expired = false; history_handler->favicon_data_.icon_url = icon_url; - scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); + scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data()); history_handler->favicon_data_.image_data = data; @@ -679,7 +679,7 @@ TEST_F(FaviconHandlerTest, Download2ndFaviconURLCandidate) { history_handler->favicon_data_.icon_type = history::TOUCH_ICON; history_handler->favicon_data_.expired = true; history_handler->favicon_data_.icon_url = new_icon_url; - scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); + scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data()); history_handler->favicon_data_.image_data = data; history_handler->InvokeCallback(); @@ -808,7 +808,7 @@ TEST_F(FaviconHandlerTest, UpdateDuringDownloading) { handler->favicon_data_.expired = false; handler->favicon_data_.icon_type = history::TOUCH_ICON; handler->favicon_data_.icon_url = latest_icon_url; - scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); + scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data()); handler->favicon_data_.image_data = data; @@ -840,7 +840,7 @@ TEST_F(FaviconHandlerTest, MultipleFavicon) { history_handler->favicon_data_.icon_type = history::FAVICON; history_handler->favicon_data_.expired = false; history_handler->favicon_data_.icon_url = icon_url; - scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); + scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data()); history_handler->favicon_data_.image_data = data; @@ -915,7 +915,7 @@ TEST_F(FaviconHandlerTest, FirstFavicon) { history_handler->favicon_data_.icon_type = history::FAVICON; history_handler->favicon_data_.expired = false; history_handler->favicon_data_.icon_url = icon_url; - scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); + scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data()); history_handler->favicon_data_.image_data = data; diff --git a/chrome/browser/favicon/favicon_service.h b/chrome/browser/favicon/favicon_service.h index 2375c1c..f471edb 100644 --- a/chrome/browser/favicon/favicon_service.h +++ b/chrome/browser/favicon/favicon_service.h @@ -10,7 +10,6 @@ #include "base/callback.h" #include "base/memory/ref_counted.h" -#include "base/memory/ref_counted_memory.h" #include "chrome/browser/cancelable_request.h" #include "chrome/browser/history/history_types.h" #include "chrome/common/ref_counted_util.h" diff --git a/chrome/browser/history/android/android_provider_backend_unittest.cc b/chrome/browser/history/android/android_provider_backend_unittest.cc index 7ff6936..77e7bb2 100644 --- a/chrome/browser/history/android/android_provider_backend_unittest.cc +++ b/chrome/browser/history/android/android_provider_backend_unittest.cc @@ -210,7 +210,10 @@ TEST_F(AndroidProviderBackendTest, UpdateTables) { // Set favicon to url2. std::vector<unsigned char> data; data.push_back('1'); - history_backend->SetFavicon(url2, GURL(), new RefCountedBytes(data), FAVICON); + history_backend->SetFavicon(url2, + GURL(), + new base::RefCountedBytes(data), + FAVICON); history_backend->Closing(); } @@ -333,7 +336,10 @@ TEST_F(AndroidProviderBackendTest, QueryHistoryAndBookmarks) { // Set favicon to url2. std::vector<unsigned char> data; data.push_back('1'); - history_backend->SetFavicon(url2, GURL(), new RefCountedBytes(data), FAVICON); + history_backend->SetFavicon(url2, + GURL(), + new base::RefCountedBytes(data), + FAVICON); history_backend->Closing(); } diff --git a/chrome/browser/history/android/favicon_sql_handler.cc b/chrome/browser/history/android/favicon_sql_handler.cc index b4f948d..d3c49b0 100644 --- a/chrome/browser/history/android/favicon_sql_handler.cc +++ b/chrome/browser/history/android/favicon_sql_handler.cc @@ -38,7 +38,7 @@ bool FaviconSQLHandler::Update(const HistoryAndBookmarkRow& row, return false; scoped_refptr<RefCountedMemory> image_data = - new RefCountedBytes(row.favicon()); + new base::RefCountedBytes(row.favicon()); if (!thumbnail_db_->SetFavicon(favicon_id, image_data, Time::Now())) return false; } @@ -114,7 +114,7 @@ bool FaviconSQLHandler::Insert(HistoryAndBookmarkRow* row) { return false; scoped_refptr<RefCountedMemory> image_data = - new RefCountedBytes(row->favicon()); + new base::RefCountedBytes(row->favicon()); if (!thumbnail_db_->SetFavicon(id, image_data, Time::Now())) return false; return thumbnail_db_->AddIconMapping(row->url(), id); diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc index 9e234eb..a43de71 100644 --- a/chrome/browser/history/history.cc +++ b/chrome/browser/history/history.cc @@ -498,7 +498,7 @@ void HistoryService::SetFavicon(const GURL& page_url, ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetFavicon, page_url, icon_url, - scoped_refptr<RefCountedMemory>(new RefCountedBytes(image_data)), + scoped_refptr<RefCountedMemory>(new base::RefCountedBytes(image_data)), icon_type); } diff --git a/chrome/browser/history/history.h b/chrome/browser/history/history.h index 67089a0..e3a24e7 100644 --- a/chrome/browser/history/history.h +++ b/chrome/browser/history/history.h @@ -390,7 +390,7 @@ class HistoryService : public CancelableRequestProvider, // // This function will be called even on error conditions or if there is no // thumbnail for that page. In these cases, the data pointer will be NULL. - typedef base::Callback<void(Handle, scoped_refptr<RefCountedBytes>)> + typedef base::Callback<void(Handle, scoped_refptr<base::RefCountedBytes>)> ThumbnailDataCallback; // Requests a page thumbnail. See ThumbnailDataCallback definition above. diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc index 7f3bafb..42c33e0 100644 --- a/chrome/browser/history/history_backend.cc +++ b/chrome/browser/history/history_backend.cc @@ -1678,7 +1678,7 @@ void HistoryBackend::GetPageThumbnail( if (request->canceled()) return; - scoped_refptr<RefCountedBytes> data; + scoped_refptr<base::RefCountedBytes> data; GetPageThumbnailDirectly(page_url, &data); request->ForwardResult(request->handle(), data); @@ -1686,9 +1686,9 @@ void HistoryBackend::GetPageThumbnail( void HistoryBackend::GetPageThumbnailDirectly( const GURL& page_url, - scoped_refptr<RefCountedBytes>* data) { + scoped_refptr<base::RefCountedBytes>* data) { if (thumbnail_db_.get()) { - *data = new RefCountedBytes; + *data = new base::RefCountedBytes; // Time the result. TimeTicks beginning_time = TimeTicks::Now(); @@ -1831,7 +1831,7 @@ void HistoryBackend::SetImportedFavicons( if (!favicon_id) continue; // Unable to add the favicon. thumbnail_db_->SetFavicon(favicon_id, - new RefCountedBytes(favicon_usage[i].png_data), now); + new base::RefCountedBytes(favicon_usage[i].png_data), now); } // Save the mapping from all the URLs to the favicon. @@ -1894,7 +1894,7 @@ void HistoryBackend::UpdateFaviconMappingAndFetchImpl( thumbnail_db_->GetFaviconIDForFaviconURL( icon_url, icon_types, &favicon.icon_type); if (favicon_id) { - scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); + scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); favicon.known_icon = true; Time last_updated; if (thumbnail_db_->GetFavicon(favicon_id, &last_updated, &data->data(), @@ -2464,7 +2464,7 @@ bool HistoryBackend::GetFaviconFromDB( bool HistoryBackend::GetFaviconFromDB(FaviconID favicon_id, FaviconData* favicon) { Time last_updated; - scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); + scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); if (!thumbnail_db_->GetFavicon(favicon_id, &last_updated, &data->data(), &favicon->icon_url, &favicon->icon_type)) diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h index 771eb2a..0e31679 100644 --- a/chrome/browser/history/history_backend.h +++ b/chrome/browser/history/history_backend.h @@ -236,7 +236,7 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, // Exposed for testing reasons. void GetPageThumbnailDirectly( const GURL& page_url, - scoped_refptr<RefCountedBytes>* data); + scoped_refptr<base::RefCountedBytes>* data); void MigrateThumbnailsDatabase(); diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc index c8622e2..291056c 100644 --- a/chrome/browser/history/history_backend_unittest.cc +++ b/chrome/browser/history/history_backend_unittest.cc @@ -287,11 +287,11 @@ TEST_F(HistoryBackendTest, DeleteAll) { std::vector<unsigned char> data; data.push_back('1'); EXPECT_TRUE(backend_->thumbnail_db_->SetFavicon(favicon1, - new RefCountedBytes(data), Time::Now())); + new base::RefCountedBytes(data), Time::Now())); data[0] = '2'; EXPECT_TRUE(backend_->thumbnail_db_->SetFavicon( - favicon2, new RefCountedBytes(data), Time::Now())); + favicon2, new base::RefCountedBytes(data), Time::Now())); // First visit two URLs. URLRow row1(GURL("http://www.google.com/")); @@ -476,11 +476,11 @@ TEST_F(HistoryBackendTest, URLsNoLongerBookmarked) { std::vector<unsigned char> data; data.push_back('1'); EXPECT_TRUE(backend_->thumbnail_db_->SetFavicon( - favicon1, new RefCountedBytes(data), Time::Now())); + favicon1, new base::RefCountedBytes(data), Time::Now())); data[0] = '2'; EXPECT_TRUE(backend_->thumbnail_db_->SetFavicon( - favicon2, new RefCountedBytes(data), Time::Now())); + favicon2, new base::RefCountedBytes(data), Time::Now())); // First visit two URLs. URLRow row1(GURL("http://www.google.com/")); @@ -650,7 +650,7 @@ TEST_F(HistoryBackendTest, ImportedFaviconsTest) { std::vector<unsigned char> data; data.push_back('1'); EXPECT_TRUE(backend_->thumbnail_db_->SetFavicon(favicon1, - RefCountedBytes::TakeVector(&data), Time::Now())); + base::RefCountedBytes::TakeVector(&data), Time::Now())); URLRow row1(GURL("http://www.google.com/")); row1.set_visit_count(1); row1.set_last_visit(Time::Now()); @@ -1069,7 +1069,7 @@ TEST_F(HistoryBackendTest, SetFaviconMapping) { std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); // Add a favicon backend_->SetFavicon( - url1, icon_url, RefCountedBytes::TakeVector(&data), FAVICON); + url1, icon_url, base::RefCountedBytes::TakeVector(&data), FAVICON); EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( url1, FAVICON, NULL)); EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( @@ -1077,7 +1077,7 @@ TEST_F(HistoryBackendTest, SetFaviconMapping) { // Add a touch_icon backend_->SetFavicon( - url1, icon_url, RefCountedBytes::TakeVector(&data), TOUCH_ICON); + url1, icon_url, base::RefCountedBytes::TakeVector(&data), TOUCH_ICON); EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( url1, TOUCH_ICON, NULL)); EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( @@ -1088,7 +1088,7 @@ TEST_F(HistoryBackendTest, SetFaviconMapping) { // Add a TOUCH_PRECOMPOSED_ICON backend_->SetFavicon(url1, icon_url, - RefCountedBytes::TakeVector(&data), + base::RefCountedBytes::TakeVector(&data), TOUCH_PRECOMPOSED_ICON); // The touch_icon was replaced. EXPECT_FALSE(backend_->thumbnail_db_->GetIconMappingForPageURL( @@ -1102,7 +1102,7 @@ TEST_F(HistoryBackendTest, SetFaviconMapping) { // Add a touch_icon backend_->SetFavicon( - url1, icon_url, RefCountedBytes::TakeVector(&data), TOUCH_ICON); + url1, icon_url, base::RefCountedBytes::TakeVector(&data), TOUCH_ICON); EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( url1, TOUCH_ICON, NULL)); EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( @@ -1114,7 +1114,7 @@ TEST_F(HistoryBackendTest, SetFaviconMapping) { // Add a favicon const GURL icon_url2("http://www.google.com/icon2"); backend_->SetFavicon( - url1, icon_url2, RefCountedBytes::TakeVector(&data), FAVICON); + url1, icon_url2, base::RefCountedBytes::TakeVector(&data), FAVICON); FaviconID icon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( icon_url2, FAVICON, NULL); EXPECT_NE(0, icon_id); @@ -1134,7 +1134,7 @@ TEST_F(HistoryBackendTest, AddOrUpdateIconMapping) { std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); backend_->SetFavicon( - url, icon_url, RefCountedBytes::TakeVector(&data), FAVICON); + url, icon_url, base::RefCountedBytes::TakeVector(&data), FAVICON); FaviconID icon_id = backend_->thumbnail_db_->GetFaviconIDForFaviconURL( icon_url, FAVICON, NULL); @@ -1156,7 +1156,7 @@ TEST_F(HistoryBackendTest, GetFaviconForURL) { const GURL url("http://www.google.com/"); const GURL icon_url("http://www.google.com/icon"); std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); - scoped_refptr<RefCountedBytes> bytes(new RefCountedBytes(data)); + scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); // Used for testing the icon data after getting from DB std::string blob_data(bytes->front(), bytes->front() + bytes->size()); @@ -1203,7 +1203,7 @@ TEST_F(HistoryBackendTest, CloneFaviconIsRestrictedToSameDomain) { // Add a favicon std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); - scoped_refptr<RefCountedBytes> bytes(new RefCountedBytes(data)); + scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); backend_->SetFavicon( url, icon_url, bytes.get(), FAVICON); EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( diff --git a/chrome/browser/history/history_types.h b/chrome/browser/history/history_types.h index b2e7ca8..fee26a3 100644 --- a/chrome/browser/history/history_types.h +++ b/chrome/browser/history/history_types.h @@ -640,11 +640,11 @@ struct Images { Images(); ~Images(); - scoped_refptr<RefCountedBytes> thumbnail; + scoped_refptr<base::RefCountedBytes> thumbnail; ThumbnailScore thumbnail_score; // TODO(brettw): this will eventually store the favicon. - // scoped_refptr<RefCountedBytes> favicon; + // scoped_refptr<base::RefCountedBytes> favicon; }; typedef std::vector<MostVisitedURL> MostVisitedURLList; @@ -665,7 +665,7 @@ struct TopSitesDelta { MostVisitedURLWithRankList moved; }; -typedef std::map<GURL, scoped_refptr<RefCountedBytes> > URLToThumbnailMap; +typedef std::map<GURL, scoped_refptr<base::RefCountedBytes> > URLToThumbnailMap; // Used when migrating most visited thumbnails out of history and into topsites. struct ThumbnailMigration { diff --git a/chrome/browser/history/thumbnail_database_unittest.cc b/chrome/browser/history/thumbnail_database_unittest.cc index 111a2e1..0117729 100644 --- a/chrome/browser/history/thumbnail_database_unittest.cc +++ b/chrome/browser/history/thumbnail_database_unittest.cc @@ -116,7 +116,7 @@ TEST_F(ThumbnailDatabaseTest, GetFaviconAfterMigrationToTopSites) { db.BeginTransaction(); std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); - scoped_refptr<RefCountedBytes> favicon(new RefCountedBytes(data)); + scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); GURL url("http://google.com"); FaviconID id = db.AddFavicon(url, FAVICON); @@ -146,7 +146,7 @@ TEST_F(ThumbnailDatabaseTest, AddIconMapping) { db.BeginTransaction(); std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); - scoped_refptr<RefCountedBytes> favicon(new RefCountedBytes(data)); + scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); GURL url("http://google.com"); FaviconID id = db.AddFavicon(url, TOUCH_ICON); @@ -168,7 +168,7 @@ TEST_F(ThumbnailDatabaseTest, UpdateIconMapping) { db.BeginTransaction(); std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); - scoped_refptr<RefCountedBytes> favicon(new RefCountedBytes(data)); + scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); GURL url("http://google.com"); FaviconID id = db.AddFavicon(url, TOUCH_ICON); @@ -200,7 +200,7 @@ TEST_F(ThumbnailDatabaseTest, DeleteIconMappings) { db.BeginTransaction(); std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); - scoped_refptr<RefCountedBytes> favicon(new RefCountedBytes(data)); + scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); GURL url("http://google.com"); FaviconID id = db.AddFavicon(url, TOUCH_ICON); @@ -231,7 +231,7 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURL) { db.BeginTransaction(); std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); - scoped_refptr<RefCountedBytes> favicon(new RefCountedBytes(data)); + scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); GURL url("http://google.com"); @@ -276,7 +276,7 @@ TEST_F(ThumbnailDatabaseTest, UpgradeToVersion4) { EXPECT_TRUE(db.UpgradeToVersion4()); std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); - scoped_refptr<RefCountedBytes> favicon(new RefCountedBytes(data)); + scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); GURL url("http://google.com"); FaviconID id = db.AddFavicon(url, TOUCH_ICON); @@ -328,7 +328,7 @@ TEST_F(ThumbnailDatabaseTest, TemporayIconMapping) { EXPECT_TRUE(db.InitTemporaryIconMappingTable()); std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); - scoped_refptr<RefCountedBytes> favicon(new RefCountedBytes(data)); + scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); GURL url("http://google.com"); FaviconID id = db.AddFavicon(url, FAVICON); @@ -350,7 +350,7 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLForReturnOrder) { // Add a favicon std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); - scoped_refptr<RefCountedBytes> favicon(new RefCountedBytes(data)); + scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); GURL url("http://google.com"); FaviconID id = db.AddFavicon(url, FAVICON); @@ -367,7 +367,8 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLForReturnOrder) { // Add a touch icon std::vector<unsigned char> data2(blob2, blob2 + sizeof(blob2)); - scoped_refptr<RefCountedBytes> favicon2(new RefCountedBytes(data)); + scoped_refptr<base::RefCountedBytes> favicon2 = + new base::RefCountedBytes(data); FaviconID id2 = db.AddFavicon(url, TOUCH_ICON); db.SetFavicon(id2, favicon2, time); @@ -381,7 +382,8 @@ TEST_F(ThumbnailDatabaseTest, GetIconMappingsForPageURLForReturnOrder) { EXPECT_EQ(TOUCH_ICON, icon_mapping.front().icon_type); // Add a touch precomposed icon - scoped_refptr<RefCountedBytes> favicon3(new RefCountedBytes(data2)); + scoped_refptr<base::RefCountedBytes> favicon3 = + new base::RefCountedBytes(data2); FaviconID id3 = db.AddFavicon(url, TOUCH_PRECOMPOSED_ICON); db.SetFavicon(id3, favicon3, time); @@ -401,7 +403,7 @@ TEST_F(ThumbnailDatabaseTest, HasMappingFor) { db.BeginTransaction(); std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); - scoped_refptr<RefCountedBytes> favicon(new RefCountedBytes(data)); + scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); // Add a favicon which will have icon_mappings FaviconID id1 = db.AddFavicon(GURL("http://google.com"), FAVICON); @@ -443,7 +445,7 @@ TEST_F(ThumbnailDatabaseTest, CloneIconMapping) { db.BeginTransaction(); std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); - scoped_refptr<RefCountedBytes> favicon(new RefCountedBytes(data)); + scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); // Add a favicon which will have icon_mappings FaviconID id1 = db.AddFavicon(GURL("http://google.com"), FAVICON); @@ -559,7 +561,7 @@ TEST_F(ThumbnailDatabaseTest, IconMappingEnumerator) { db.BeginTransaction(); std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); - scoped_refptr<RefCountedBytes> favicon(new RefCountedBytes(data)); + scoped_refptr<base::RefCountedBytes> favicon(new base::RefCountedBytes(data)); GURL url("http://google.com"); FaviconID touch_icon_id1 = db.AddFavicon(url, TOUCH_ICON); diff --git a/chrome/browser/history/top_sites.cc b/chrome/browser/history/top_sites.cc index ac13506..8d1e59ac 100644 --- a/chrome/browser/history/top_sites.cc +++ b/chrome/browser/history/top_sites.cc @@ -102,7 +102,7 @@ class LoadThumbnailsFromHistoryTask : public HistoryDBTask { for (size_t i = 0; i < data_.most_visited.size(); ++i) { const GURL& url = data_.most_visited[i].url; if (ShouldFetchThumbnailFor(url)) { - scoped_refptr<RefCountedBytes> data; + scoped_refptr<base::RefCountedBytes> data; backend->GetPageThumbnailDirectly(url, &data); data_.url_to_thumbnail_map[url] = data; } @@ -200,7 +200,7 @@ bool TopSites::SetPageThumbnail(const GURL& url, if (!HistoryService::CanAddURL(url)) return false; // It's not a real webpage. - scoped_refptr<RefCountedBytes> thumbnail_data; + scoped_refptr<base::RefCountedBytes> thumbnail_data; if (!EncodeBitmap(thumbnail, &thumbnail_data)) return false; @@ -500,7 +500,7 @@ TopSites::~TopSites() { } bool TopSites::SetPageThumbnailNoDB(const GURL& url, - const RefCountedBytes* thumbnail_data, + const base::RefCountedBytes* thumbnail_data, const ThumbnailScore& score) { // This should only be invoked when we know about the url. DCHECK(cache_->IsKnownURL(url)); @@ -521,7 +521,7 @@ bool TopSites::SetPageThumbnailNoDB(const GURL& url, image->thumbnail.get()) return false; // The one we already have is better. - image->thumbnail = const_cast<RefCountedBytes*>(thumbnail_data); + image->thumbnail = const_cast<base::RefCountedBytes*>(thumbnail_data); image->thumbnail_score = new_score_with_redirects; ResetThreadSafeImageCache(); @@ -529,7 +529,7 @@ bool TopSites::SetPageThumbnailNoDB(const GURL& url, } bool TopSites::SetPageThumbnailEncoded(const GURL& url, - const RefCountedBytes* thumbnail, + const base::RefCountedBytes* thumbnail, const ThumbnailScore& score) { if (!SetPageThumbnailNoDB(url, thumbnail, score)) return false; @@ -548,10 +548,10 @@ bool TopSites::SetPageThumbnailEncoded(const GURL& url, // static bool TopSites::EncodeBitmap(gfx::Image* bitmap, - scoped_refptr<RefCountedBytes>* bytes) { + scoped_refptr<base::RefCountedBytes>* bytes) { if (!bitmap) return false; - *bytes = new RefCountedBytes(); + *bytes = new base::RefCountedBytes(); std::vector<unsigned char> data; if (!gfx::JPEGEncodedDataFromImage(*bitmap, kTopSitesImageQuality, &data)) return false; @@ -574,14 +574,14 @@ void TopSites::RemoveTemporaryThumbnailByURL(const GURL& url) { } void TopSites::AddTemporaryThumbnail(const GURL& url, - const RefCountedBytes* thumbnail, + const base::RefCountedBytes* thumbnail, const ThumbnailScore& score) { if (temp_images_.size() == kMaxTempTopImages) temp_images_.erase(temp_images_.begin()); TempImage image; image.first = url; - image.second.thumbnail = const_cast<RefCountedBytes*>(thumbnail); + image.second.thumbnail = const_cast<base::RefCountedBytes*>(thumbnail); image.second.thumbnail_score = score; temp_images_.push_back(image); } diff --git a/chrome/browser/history/top_sites.h b/chrome/browser/history/top_sites.h index 9288b31..e709055 100644 --- a/chrome/browser/history/top_sites.h +++ b/chrome/browser/history/top_sites.h @@ -212,19 +212,19 @@ class TopSites // reading last known top sites from the DB. // Returns true if the thumbnail was set, false if the existing one is better. bool SetPageThumbnailNoDB(const GURL& url, - const RefCountedBytes* thumbnail_data, + const base::RefCountedBytes* thumbnail_data, const ThumbnailScore& score); // A version of SetPageThumbnail that takes RefCountedBytes as // returned by HistoryService. bool SetPageThumbnailEncoded(const GURL& url, - const RefCountedBytes* thumbnail, + const base::RefCountedBytes* thumbnail, const ThumbnailScore& score); // Encodes the bitmap to bytes for storage to the db. Returns true if the // bitmap was successfully encoded. static bool EncodeBitmap(gfx::Image* bitmap, - scoped_refptr<RefCountedBytes>* bytes); + scoped_refptr<base::RefCountedBytes>* bytes); // Removes the cached thumbnail for url. Does nothing if |url| if not cached // in |temp_images_|. @@ -232,7 +232,7 @@ class TopSites // Add a thumbnail for an unknown url. See temp_thumbnails_map_. void AddTemporaryThumbnail(const GURL& url, - const RefCountedBytes* thumbnail, + const base::RefCountedBytes* thumbnail, const ThumbnailScore& score); // Called by our timer. Starts the query for the most visited sites. diff --git a/chrome/browser/history/top_sites_cache.cc b/chrome/browser/history/top_sites_cache.cc index 802be7a..b5c5ae3 100644 --- a/chrome/browser/history/top_sites_cache.cc +++ b/chrome/browser/history/top_sites_cache.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -33,7 +33,7 @@ bool TopSitesCache::GetPageThumbnail(const GURL& url, std::map<GURL, Images>::const_iterator found = images_.find(GetCanonicalURL(url)); if (found != images_.end()) { - RefCountedBytes* data = found->second.thumbnail.get(); + base::RefCountedBytes* data = found->second.thumbnail.get(); if (data) { *bytes = data; return true; diff --git a/chrome/browser/history/top_sites_database.cc b/chrome/browser/history/top_sites_database.cc index 59c1ab3..dce0ce4 100644 --- a/chrome/browser/history/top_sites_database.cc +++ b/chrome/browser/history/top_sites_database.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/file_util.h" +#include "base/memory/ref_counted.h" #include "base/string_split.h" #include "base/string_util.h" #include "chrome/browser/diagnostics/sqlite_diagnostics.h" @@ -143,7 +144,7 @@ void TopSitesDatabase::GetPageThumbnails(MostVisitedURLList* urls, statement.ColumnBlobAsVector(3, &data); Images thumbnail; if (!data.empty()) - thumbnail.thumbnail = RefCountedBytes::TakeVector(&data); + thumbnail.thumbnail = base::RefCountedBytes::TakeVector(&data); thumbnail.thumbnail_score.boring_score = statement.ColumnDouble(5); thumbnail.thumbnail_score.good_clipping = statement.ColumnBool(6); thumbnail.thumbnail_score.at_top = statement.ColumnBool(7); @@ -309,7 +310,7 @@ bool TopSitesDatabase::GetPageThumbnail(const GURL& url, std::vector<unsigned char> data; statement.ColumnBlobAsVector(0, &data); - thumbnail->thumbnail = RefCountedBytes::TakeVector(&data); + thumbnail->thumbnail = base::RefCountedBytes::TakeVector(&data); thumbnail->thumbnail_score.boring_score = statement.ColumnDouble(1); thumbnail->thumbnail_score.good_clipping = statement.ColumnBool(2); thumbnail->thumbnail_score.at_top = statement.ColumnBool(3); diff --git a/chrome/browser/history/top_sites_database.h b/chrome/browser/history/top_sites_database.h index a8d2168..55f31a1 100644 --- a/chrome/browser/history/top_sites_database.h +++ b/chrome/browser/history/top_sites_database.h @@ -10,7 +10,6 @@ #include <string> #include "base/gtest_prod_util.h" -#include "base/memory/ref_counted.h" #include "chrome/browser/history/history_types.h" #include "chrome/browser/history/url_database.h" // For DBCloseScoper. #include "sql/meta_table.h" diff --git a/chrome/browser/history/top_sites_unittest.cc b/chrome/browser/history/top_sites_unittest.cc index 1fe773e..36d49d6 100644 --- a/chrome/browser/history/top_sites_unittest.cc +++ b/chrome/browser/history/top_sites_unittest.cc @@ -270,7 +270,7 @@ class TopSitesTest : public HistoryUnitTestBase { // Returns true if the thumbnail equals the specified bytes. bool ThumbnailEqualsBytes(const gfx::Image& image, RefCountedMemory* bytes) { - scoped_refptr<RefCountedBytes> encoded_image; + scoped_refptr<base::RefCountedBytes> encoded_image; gfx::Image copy(image); // EncodeBitmap() doesn't accept const images. TopSites::EncodeBitmap(©, &encoded_image); return ThumbnailsAreEqual(encoded_image, bytes); diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc index c495bac..50c466d 100644 --- a/chrome/browser/printing/print_dialog_cloud.cc +++ b/chrome/browser/printing/print_dialog_cloud.cc @@ -613,7 +613,7 @@ bool CloudPrintHtmlDialogDelegate::HandleContextMenu( return true; } -void CreatePrintDialogForBytesImpl(scoped_refptr<RefCountedBytes> data, +void CreatePrintDialogForBytesImpl(scoped_refptr<base::RefCountedBytes> data, const string16& print_job_title, const string16& print_ticket, const std::string& file_type, @@ -786,7 +786,7 @@ void CreateCloudPrintSigninDialog(const base::Closure& callback) { callback)); } -void CreatePrintDialogForBytes(scoped_refptr<RefCountedBytes> data, +void CreatePrintDialogForBytes(scoped_refptr<base::RefCountedBytes> data, const string16& print_job_title, const string16& print_ticket, const std::string& file_type, @@ -794,7 +794,8 @@ void CreatePrintDialogForBytes(scoped_refptr<RefCountedBytes> data, // TODO(abodenha@chromium.org) Avoid cloning the PDF data. Make use of a // shared memory object instead. // http://code.google.com/p/chromium/issues/detail?id=44093 - scoped_refptr<RefCountedBytes> cloned_data(new RefCountedBytes(data->data())); + scoped_refptr<base::RefCountedBytes> cloned_data = + new base::RefCountedBytes(data->data()); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, base::Bind(&internal_cloud_print_helpers::CreatePrintDialogForBytesImpl, diff --git a/chrome/browser/printing/print_dialog_cloud.h b/chrome/browser/printing/print_dialog_cloud.h index 6c0e640..2eca2a0 100644 --- a/chrome/browser/printing/print_dialog_cloud.h +++ b/chrome/browser/printing/print_dialog_cloud.h @@ -31,7 +31,7 @@ void CreatePrintDialogForFile(const FilePath& path_to_file, // Creates a print dialog to print data in RAM. // Called on the FILE or UI thread. Even though this may start up a modal // dialog, it will return immediately. The dialog is handled asynchronously. -void CreatePrintDialogForBytes(scoped_refptr<RefCountedBytes> data, +void CreatePrintDialogForBytes(scoped_refptr<base::RefCountedBytes> data, const string16& print_job_title, const string16& print_ticket, const std::string& file_type, diff --git a/chrome/browser/printing/print_preview_data_service.cc b/chrome/browser/printing/print_preview_data_service.cc index 1728158..3550118 100644 --- a/chrome/browser/printing/print_preview_data_service.cc +++ b/chrome/browser/printing/print_preview_data_service.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -28,7 +28,8 @@ class PrintPreviewDataStore : public base::RefCounted<PrintPreviewDataStore> { PrintPreviewDataStore() {} // Get the preview page for the specified |index|. - void GetPreviewDataForIndex(int index, scoped_refptr<RefCountedBytes>* data) { + void GetPreviewDataForIndex(int index, + scoped_refptr<base::RefCountedBytes>* data) { if (index != printing::COMPLETE_PREVIEW_DOCUMENT_INDEX && index < printing::FIRST_PAGE_INDEX) { return; @@ -40,13 +41,13 @@ class PrintPreviewDataStore : public base::RefCounted<PrintPreviewDataStore> { } // Set/Update the preview data entry for the specified |index|. - void SetPreviewDataForIndex(int index, const RefCountedBytes* data) { + void SetPreviewDataForIndex(int index, const base::RefCountedBytes* data) { if (index != printing::COMPLETE_PREVIEW_DOCUMENT_INDEX && index < printing::FIRST_PAGE_INDEX) { return; } - page_data_map_[index] = const_cast<RefCountedBytes*>(data); + page_data_map_[index] = const_cast<base::RefCountedBytes*>(data); } // Returns the available draft page count. @@ -67,7 +68,8 @@ class PrintPreviewDataStore : public base::RefCounted<PrintPreviewDataStore> { // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to represent complete preview // document. // Value: Preview data. - typedef std::map<int, scoped_refptr<RefCountedBytes> > PreviewPageDataMap; + typedef std::map<int, scoped_refptr<base::RefCountedBytes> > + PreviewPageDataMap; ~PrintPreviewDataStore() {} @@ -90,7 +92,7 @@ PrintPreviewDataService::~PrintPreviewDataService() { void PrintPreviewDataService::GetDataEntry( const std::string& preview_ui_addr_str, int index, - scoped_refptr<RefCountedBytes>* data_bytes) { + scoped_refptr<base::RefCountedBytes>* data_bytes) { *data_bytes = NULL; PreviewDataStoreMap::iterator it = data_store_map_.find(preview_ui_addr_str); if (it != data_store_map_.end()) @@ -100,7 +102,7 @@ void PrintPreviewDataService::GetDataEntry( void PrintPreviewDataService::SetDataEntry( const std::string& preview_ui_addr_str, int index, - const RefCountedBytes* data_bytes) { + const base::RefCountedBytes* data_bytes) { PreviewDataStoreMap::iterator it = data_store_map_.find(preview_ui_addr_str); if (it == data_store_map_.end()) data_store_map_[preview_ui_addr_str] = new PrintPreviewDataStore(); diff --git a/chrome/browser/printing/print_preview_data_service.h b/chrome/browser/printing/print_preview_data_service.h index 3642876..0dd4f23 100644 --- a/chrome/browser/printing/print_preview_data_service.h +++ b/chrome/browser/printing/print_preview_data_service.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -14,7 +14,10 @@ template<typename T> struct DefaultSingletonTraits; class PrintPreviewDataStore; + +namespace base { class RefCountedBytes; +} // PrintPreviewDataService manages data stores for chrome://print requests. // It owns the data store object and is responsible for freeing it. @@ -27,7 +30,7 @@ class PrintPreviewDataService { // data. Use |index| to retrieve a specific preview page data. |data| is set // to NULL if the requested page is not yet available. void GetDataEntry(const std::string& preview_ui_addr_str, int index, - scoped_refptr<RefCountedBytes>* data); + scoped_refptr<base::RefCountedBytes>* data); // Set/Update the data entry in PrintPreviewDataStore. |index| is zero-based // or |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to represent complete @@ -35,7 +38,7 @@ class PrintPreviewDataService { // NOTE: PrintPreviewDataStore owns the data. Do not refcount |data| before // calling this function. It will be refcounted in PrintPreviewDataStore. void SetDataEntry(const std::string& preview_ui_addr_str, int index, - const RefCountedBytes* data); + const base::RefCountedBytes* data); // Remove the corresponding PrintPreviewUI entry from the map. void RemoveEntry(const std::string& preview_ui_addr_str); diff --git a/chrome/browser/printing/print_preview_message_handler.cc b/chrome/browser/printing/print_preview_message_handler.cc index 7dd0a96..b97fbd9 100644 --- a/chrome/browser/printing/print_preview_message_handler.cc +++ b/chrome/browser/printing/print_preview_message_handler.cc @@ -46,8 +46,8 @@ void StopWorker(int document_cookie) { } } -RefCountedBytes* GetDataFromHandle(base::SharedMemoryHandle handle, - uint32 data_size) { +base::RefCountedBytes* GetDataFromHandle(base::SharedMemoryHandle handle, + uint32 data_size) { scoped_ptr<base::SharedMemory> shared_buf( new base::SharedMemory(handle, true)); if (!shared_buf->Map(data_size)) { @@ -58,7 +58,7 @@ RefCountedBytes* GetDataFromHandle(base::SharedMemoryHandle handle, char* preview_data = static_cast<char*>(shared_buf->memory()); std::vector<unsigned char> data(data_size); memcpy(&data[0], preview_data, data_size); - return RefCountedBytes::TakeVector(&data); + return base::RefCountedBytes::TakeVector(&data); } } // namespace @@ -132,7 +132,7 @@ void PrintPreviewMessageHandler::OnDidPreviewPage( if (!print_preview_ui) return; - RefCountedBytes* data_bytes = + base::RefCountedBytes* data_bytes = GetDataFromHandle(params.metafile_data_handle, params.data_size); DCHECK(data_bytes); @@ -169,7 +169,7 @@ void PrintPreviewMessageHandler::OnMetafileReadyForPrinting( // TODO(joth): This seems like a good match for using RefCountedStaticMemory // to avoid the memory copy, but the SetPrintPreviewData call chain below // needs updating to accept the RefCountedMemory* base class. - RefCountedBytes* data_bytes = + base::RefCountedBytes* data_bytes = GetDataFromHandle(params.metafile_data_handle, params.data_size); if (!data_bytes) return; diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc index 448e566..85b55a3 100644 --- a/chrome/browser/themes/browser_theme_pack.cc +++ b/chrome/browser/themes/browser_theme_pack.cc @@ -297,7 +297,7 @@ RefCountedMemory* ReadFileData(const FilePath& path) { raw_data.resize(size); char* data = reinterpret_cast<char*>(&(raw_data.front())); if (file.ReadUntilComplete(data, size) == avail) - return RefCountedBytes::TakeVector(&raw_data); + return base::RefCountedBytes::TakeVector(&raw_data); } } } @@ -1028,7 +1028,8 @@ void BrowserThemePack::RepackImages(const ImageCache& images, NOTREACHED() << "Image file for resource " << it->first << " could not be encoded."; } else { - (*reencoded_images)[it->first] = RefCountedBytes::TakeVector(&image_data); + (*reencoded_images)[it->first] = + base::RefCountedBytes::TakeVector(&image_data); } } } diff --git a/chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm b/chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm index 0632884..a143e43 100644 --- a/chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm +++ b/chrome/browser/ui/cocoa/history_menu_bridge_unittest.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -372,7 +372,7 @@ TEST_F(HistoryMenuBridgeTest, GotFaviconData) { // Pretend to be called back. history::FaviconData favicon; favicon.known_icon = true; - favicon.image_data = new RefCountedBytes(raw); + favicon.image_data = new base::RefCountedBytes(raw); favicon.expired = false; favicon.icon_url = GURL(); favicon.icon_type = history::FAVICON; diff --git a/chrome/browser/ui/views/ash/screenshot_taker.cc b/chrome/browser/ui/views/ash/screenshot_taker.cc index ce4f2b1..100113a 100644 --- a/chrome/browser/ui/views/ash/screenshot_taker.cc +++ b/chrome/browser/ui/views/ash/screenshot_taker.cc @@ -36,7 +36,7 @@ std::string GetScreenshotFileName() { // |is_logged_in| is used only for ChromeOS. Otherwise it is always true. void SaveScreenshot(bool is_logged_in, - scoped_refptr<RefCountedBytes> png_data) { + scoped_refptr<base::RefCountedBytes> png_data) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); std::string screenshot_filename = GetScreenshotFileName(); @@ -85,7 +85,7 @@ void ScreenshotTaker::HandleTakePartialScreenshot( aura::Window* window, const gfx::Rect& rect) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - scoped_refptr<RefCountedBytes> png_data(new RefCountedBytes); + scoped_refptr<base::RefCountedBytes> png_data(new base::RefCountedBytes); bool is_logged_in = true; #if defined(OS_CHROMEOS) diff --git a/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc b/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc index 8cc91f5..0c99d0e 100644 --- a/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc +++ b/chrome/browser/ui/webui/chromeos/login/oobe_ui.cc @@ -86,7 +86,8 @@ void OobeUIHTMLSource::StartDataRequest(const std::string& path, if (UserManager::Get()->IsUserLoggedIn() && !UserManager::Get()->IsLoggedInAsStub() && !ScreenLocker::default_screen_locker()) { - scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes()); + scoped_refptr<base::RefCountedBytes> empty_bytes = + new base::RefCountedBytes(); SendResponse(request_id, empty_bytes); return; } diff --git a/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc b/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc index cc8ca0e..16b43ba 100644 --- a/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc +++ b/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc @@ -451,7 +451,7 @@ void MobileSetupUIHTMLSource::StartDataRequest(const std::string& path, // If we are activating, shutting down, or logging in, |network| may not // be available. if (!network || !network->SupportsActivation()) { - scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); + scoped_refptr<base::RefCountedBytes> html_bytes(new base::RefCountedBytes); SendResponse(request_id, html_bytes); return; } diff --git a/chrome/browser/ui/webui/chromeos/register_page_ui.cc b/chrome/browser/ui/webui/chromeos/register_page_ui.cc index 9959ed1..bcb4e14 100644 --- a/chrome/browser/ui/webui/chromeos/register_page_ui.cc +++ b/chrome/browser/ui/webui/chromeos/register_page_ui.cc @@ -159,7 +159,7 @@ void RegisterPageUIHTMLSource::StartDataRequest(const std::string& path, // OOBE wizard lifetime and when device has not been registered yet. if (!chromeos::WizardController::default_controller() || chromeos::WizardController::IsDeviceRegistered()) { - scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes); + scoped_refptr<base::RefCountedBytes> empty_bytes(new base::RefCountedBytes); SendResponse(request_id, empty_bytes); return; } diff --git a/chrome/browser/ui/webui/extensions/extension_icon_source.cc b/chrome/browser/ui/webui/extensions/extension_icon_source.cc index ca34c99..f37f96b 100644 --- a/chrome/browser/ui/webui/extensions/extension_icon_source.cc +++ b/chrome/browser/ui/webui/extensions/extension_icon_source.cc @@ -32,7 +32,7 @@ namespace { scoped_refptr<RefCountedMemory> BitmapToMemory(const SkBitmap* image) { - RefCountedBytes* image_bytes = new RefCountedBytes; + base::RefCountedBytes* image_bytes = new base::RefCountedBytes; gfx::PNGCodec::EncodeBGRASkBitmap(*image, false, &image_bytes->data()); return image_bytes; } diff --git a/chrome/browser/ui/webui/fileicon_source.cc b/chrome/browser/ui/webui/fileicon_source.cc index 2f2f889..04fd9c8 100644 --- a/chrome/browser/ui/webui/fileicon_source.cc +++ b/chrome/browser/ui/webui/fileicon_source.cc @@ -90,7 +90,7 @@ void FileIconSource::FetchFileIcon(const FilePath& path, gfx::Image* icon = im->LookupIcon(path, icon_size); if (icon) { - scoped_refptr<RefCountedBytes> icon_data(new RefCountedBytes); + scoped_refptr<base::RefCountedBytes> icon_data(new base::RefCountedBytes); gfx::PNGCodec::EncodeBGRASkBitmap(*icon->ToSkBitmap(), false, &icon_data->data()); @@ -127,7 +127,7 @@ void FileIconSource::OnFileIconDataAvailable(IconManager::Handle handle, int request_id = cancelable_consumer_.GetClientData(im, handle); if (icon) { - scoped_refptr<RefCountedBytes> icon_data(new RefCountedBytes); + scoped_refptr<base::RefCountedBytes> icon_data(new base::RefCountedBytes); gfx::PNGCodec::EncodeBGRASkBitmap(*icon->ToSkBitmap(), false, &icon_data->data()); diff --git a/chrome/browser/ui/webui/fileicon_source.h b/chrome/browser/ui/webui/fileicon_source.h index 84858c7..be81338 100644 --- a/chrome/browser/ui/webui/fileicon_source.h +++ b/chrome/browser/ui/webui/fileicon_source.h @@ -12,8 +12,6 @@ #include "chrome/browser/icon_manager.h" #include "chrome/browser/ui/webui/chrome_url_data_manager.h" -class RefCountedBytes; - namespace gfx { class Image; } diff --git a/chrome/browser/ui/webui/options2/chromeos/user_image_source2.cc b/chrome/browser/ui/webui/options2/chromeos/user_image_source2.cc index eae0385..03d929b 100644 --- a/chrome/browser/ui/webui/options2/chromeos/user_image_source2.cc +++ b/chrome/browser/ui/webui/options2/chromeos/user_image_source2.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -43,7 +43,7 @@ void UserImageSource::StartDataRequest(const std::string& path, // Strip the query param value - we only use it as a hack to ensure our // image gets reloaded instead of being pulled from the browser cache std::string email = path.substr(0, path.find_first_of("?")); - SendResponse(request_id, new RefCountedBytes(GetUserImage(email))); + SendResponse(request_id, new base::RefCountedBytes(GetUserImage(email))); } std::string UserImageSource::GetMimeType(const std::string&) const { diff --git a/chrome/browser/ui/webui/print_preview/print_preview_data_source.cc b/chrome/browser/ui/webui/print_preview/print_preview_data_source.cc index 2cc993f..40acd06 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_data_source.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_data_source.cc @@ -159,7 +159,7 @@ void PrintPreviewDataSource::StartDataRequest(const std::string& path, } // Print Preview data. - scoped_refptr<RefCountedBytes> data; + scoped_refptr<base::RefCountedBytes> data; std::vector<std::string> url_substr; base::SplitString(path, '/', &url_substr); int page_index = 0; @@ -172,6 +172,6 @@ void PrintPreviewDataSource::StartDataRequest(const std::string& path, return; } // Invalid request. - scoped_refptr<RefCountedBytes> empty_bytes(new RefCountedBytes); + scoped_refptr<base::RefCountedBytes> empty_bytes(new base::RefCountedBytes); SendResponse(request_id, empty_bytes); } diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc index 016c425..3b9cda3c 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc @@ -439,7 +439,7 @@ void PrintPreviewHandler::HandlePrintToPdf( web_ui()->GetController()); if (print_to_pdf_path_.get()) { // User has already selected a path, no need to show the dialog again. - scoped_refptr<RefCountedBytes> data; + scoped_refptr<base::RefCountedBytes> data; print_preview_ui->GetPrintPreviewDataForIndex( printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data); PostPrintToPdfTask(data); @@ -540,7 +540,7 @@ void PrintPreviewHandler::HandlePrintWithCloudPrint() { PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( web_ui()->GetController()); - scoped_refptr<RefCountedBytes> data; + scoped_refptr<base::RefCountedBytes> data; print_preview_ui->GetPrintPreviewDataForIndex( printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data); if (!data.get()) { @@ -709,7 +709,7 @@ void PrintPreviewHandler::SendCloudPrintEnabled() { void PrintPreviewHandler::SendCloudPrintJob(const DictionaryValue& settings, std::string print_ticket) { - scoped_refptr<RefCountedBytes> data; + scoped_refptr<base::RefCountedBytes> data; PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( web_ui()->GetController()); print_preview_ui->GetPrintPreviewDataForIndex( @@ -836,7 +836,7 @@ void PrintPreviewHandler::FileSelected(const FilePath& path, PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( web_ui()->GetController()); print_preview_ui->web_ui()->CallJavascriptFunction("fileSelectionCompleted"); - scoped_refptr<RefCountedBytes> data; + scoped_refptr<base::RefCountedBytes> data; print_preview_ui->GetPrintPreviewDataForIndex( printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data); print_to_pdf_path_.reset(new FilePath(path)); @@ -845,7 +845,7 @@ void PrintPreviewHandler::FileSelected(const FilePath& path, } void PrintPreviewHandler::PostPrintToPdfTask( - scoped_refptr<RefCountedBytes> data) { + scoped_refptr<base::RefCountedBytes> data) { printing::PreviewMetafile* metafile = new printing::PreviewMetafile; metafile->InitFromData(static_cast<const void*>(data->front()), data->size()); // PrintToPdfCallback takes ownership of |metafile|. diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.h b/chrome/browser/ui/webui/print_preview/print_preview_handler.h index fc534f6..9a1d593 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_handler.h +++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.h @@ -20,11 +20,11 @@ class FilePath; class PrintSystemTaskProxy; -class RefCountedBytes; class TabContentsWrapper; namespace base { class DictionaryValue; +class RefCountedBytes; } namespace printing { @@ -176,7 +176,7 @@ class PrintPreviewHandler : public content::WebUIMessageHandler, void ClearInitiatorTabDetails(); // Posts a task to save |data| to pdf at |print_to_pdf_path_|. - void PostPrintToPdfTask(scoped_refptr<RefCountedBytes> data); + void PostPrintToPdfTask(scoped_refptr<base::RefCountedBytes> data); // Populates |settings| according to the current locale. void GetNumberFormatAndMeasurementSystem(base::DictionaryValue* settings); diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc index 7c41091..6b9b3b4 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc @@ -7,6 +7,7 @@ #include <map> #include "base/lazy_instance.h" +#include "base/memory/ref_counted_memory.h" #include "base/metrics/histogram.h" #include "base/string_util.h" #include "base/synchronization/lock.h" @@ -108,12 +109,13 @@ PrintPreviewUI::~PrintPreviewUI() { void PrintPreviewUI::GetPrintPreviewDataForIndex( int index, - scoped_refptr<RefCountedBytes>* data) { + scoped_refptr<base::RefCountedBytes>* data) { print_preview_data_service()->GetDataEntry(preview_ui_addr_str_, index, data); } -void PrintPreviewUI::SetPrintPreviewDataForIndex(int index, - const RefCountedBytes* data) { +void PrintPreviewUI::SetPrintPreviewDataForIndex( + int index, + const base::RefCountedBytes* data) { print_preview_data_service()->SetDataEntry(preview_ui_addr_str_, index, data); } diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui.h b/chrome/browser/ui/webui/print_preview/print_preview_ui.h index 28e997d..1f5b071 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_ui.h +++ b/chrome/browser/ui/webui/print_preview/print_preview_ui.h @@ -10,7 +10,6 @@ #include "base/gtest_prod_util.h" #include "base/memory/ref_counted.h" -#include "base/memory/ref_counted_memory.h" #include "base/time.h" #include "chrome/browser/printing/print_preview_data_service.h" #include "chrome/browser/ui/webui/constrained_html_ui.h" @@ -19,6 +18,10 @@ class PrintPreviewDataService; class PrintPreviewHandler; struct PrintHostMsg_DidGetPreviewPageCount_Params; +namespace base { +class RefCountedBytes; +} + namespace gfx { class Rect; } @@ -36,12 +39,13 @@ class PrintPreviewUI : public ConstrainedHtmlUI { // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to get the entire preview // document. void GetPrintPreviewDataForIndex(int index, - scoped_refptr<RefCountedBytes>* data); + scoped_refptr<base::RefCountedBytes>* data); // Sets the print preview |data|. |index| is zero-based, and can be // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to set the entire preview // document. - void SetPrintPreviewDataForIndex(int index, const RefCountedBytes* data); + void SetPrintPreviewDataForIndex(int index, + const base::RefCountedBytes* data); // Clear the existing print preview data. void ClearAllPreviewData(); diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc index 75f9ed5..53787d3 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc @@ -67,14 +67,15 @@ TEST_F(PrintPreviewUIUnitTest, PrintPreviewData) { preview_tab->web_contents()->GetWebUI()->GetController()); ASSERT_TRUE(preview_ui != NULL); - scoped_refptr<RefCountedBytes> data; + scoped_refptr<base::RefCountedBytes> data; preview_ui->GetPrintPreviewDataForIndex( printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data); EXPECT_EQ(NULL, data.get()); std::vector<unsigned char> preview_data(blob1, blob1 + sizeof(blob1)); - scoped_refptr<RefCountedBytes> dummy_data(new RefCountedBytes(preview_data)); + scoped_refptr<base::RefCountedBytes> dummy_data = + new base::RefCountedBytes(preview_data); preview_ui->SetPrintPreviewDataForIndex( printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, @@ -86,7 +87,7 @@ TEST_F(PrintPreviewUIUnitTest, PrintPreviewData) { EXPECT_EQ(dummy_data.get(), data.get()); // This should not cause any memory leaks. - dummy_data = new RefCountedBytes(); + dummy_data = new base::RefCountedBytes(); preview_ui->SetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX, dummy_data); @@ -121,12 +122,13 @@ TEST_F(PrintPreviewUIUnitTest, PrintPreviewDraftPages) { preview_tab->web_contents()->GetWebUI()->GetController()); ASSERT_TRUE(preview_ui != NULL); - scoped_refptr<RefCountedBytes> data; + scoped_refptr<base::RefCountedBytes> data; preview_ui->GetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX, &data); EXPECT_EQ(NULL, data.get()); std::vector<unsigned char> preview_data(blob1, blob1 + sizeof(blob1)); - scoped_refptr<RefCountedBytes> dummy_data(new RefCountedBytes(preview_data)); + scoped_refptr<base::RefCountedBytes> dummy_data = + new base::RefCountedBytes(preview_data); preview_ui->SetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX, dummy_data.get()); diff --git a/chrome/browser/ui/webui/screenshot_source.cc b/chrome/browser/ui/webui/screenshot_source.cc index 4a55a1d..96f6630 100644 --- a/chrome/browser/ui/webui/screenshot_source.cc +++ b/chrome/browser/ui/webui/screenshot_source.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -114,5 +114,5 @@ void ScreenshotSource::CacheAndSendScreenshot( int request_id, ScreenshotDataPtr bytes) { cached_screenshots_[screenshot_path] = bytes; - SendResponse(request_id, new RefCountedBytes(*bytes)); + SendResponse(request_id, new base::RefCountedBytes(*bytes)); } diff --git a/content/test/render_widget_browsertest.cc b/content/test/render_widget_browsertest.cc index 6f85dba..f9f034a 100644 --- a/content/test/render_widget_browsertest.cc +++ b/content/test/render_widget_browsertest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -130,7 +130,7 @@ bool RenderWidgetTest::ImageContainsColor(const SkBitmap& bitmap, void RenderWidgetTest::OutputBitmapToFile(const SkBitmap& bitmap, const FilePath& file_path) { - scoped_refptr<RefCountedBytes> bitmap_data(new RefCountedBytes()); + scoped_refptr<base::RefCountedBytes> bitmap_data(new base::RefCountedBytes()); SkAutoLockPixels lock(bitmap); ASSERT_TRUE(gfx::JPEGCodec::Encode( reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), diff --git a/ui/gfx/color_analysis_unittest.cc b/ui/gfx/color_analysis_unittest.cc index 7ff927d..a723520 100644 --- a/ui/gfx/color_analysis_unittest.cc +++ b/ui/gfx/color_analysis_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -134,8 +134,8 @@ TEST_F(ColorAnalysisTest, CalculatePNGKMeanAllWhite) { MockKMeanImageSampler test_sampler; test_sampler.AddSample(0); - scoped_refptr<RefCountedBytes> png( - new RefCountedBytes( + scoped_refptr<base::RefCountedBytes> png( + new base::RefCountedBytes( std::vector<unsigned char>( k1x1White, k1x1White + sizeof(k1x1White) / sizeof(unsigned char)))); @@ -151,8 +151,8 @@ TEST_F(ColorAnalysisTest, CalculatePNGKMeanIgnoreWhite) { test_sampler.AddSample(1); test_sampler.AddSample(2); - scoped_refptr<RefCountedBytes> png( - new RefCountedBytes( + scoped_refptr<base::RefCountedBytes> png( + new base::RefCountedBytes( std::vector<unsigned char>( k1x3BlueWhite, k1x3BlueWhite + sizeof(k1x3BlueWhite) / sizeof(unsigned char)))); @@ -168,8 +168,8 @@ TEST_F(ColorAnalysisTest, CalculatePNGKMeanPickMostCommon) { test_sampler.AddSample(1); test_sampler.AddSample(2); - scoped_refptr<RefCountedBytes> png( - new RefCountedBytes( + scoped_refptr<base::RefCountedBytes> png( + new base::RefCountedBytes( std::vector<unsigned char>( k1x3BlueRed, k1x3BlueRed + sizeof(k1x3BlueRed) / sizeof(unsigned char)))); |