summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history/android
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-17 22:36:34 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-17 22:36:34 +0000
commit3188e2314b27ec1f7eed8a7362d8509595e60925 (patch)
tree5ff2e939c79a43e42d732ee5b6fbe9184e434e0d /chrome/browser/history/android
parent0e88913728014a31dddfcbc6e7224cd8b90d9518 (diff)
downloadchromium_src-3188e2314b27ec1f7eed8a7362d8509595e60925.zip
chromium_src-3188e2314b27ec1f7eed8a7362d8509595e60925.tar.gz
chromium_src-3188e2314b27ec1f7eed8a7362d8509595e60925.tar.bz2
Revert 152162 - Change HistoryAndBookmarkRow favicon_ field to be scoped_refptr<base::RefCountedMemory> instead of std::vector<unsigned char>
Bug=138553 Test=Compiles R=michaelbai TBR=sky Review URL: https://chromiumcodereview.appspot.com/10831341 TBR=pkotwicz@chromium.org Review URL: https://chromiumcodereview.appspot.com/10857065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152169 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history/android')
-rw-r--r--chrome/browser/history/android/android_history_types.h10
-rw-r--r--chrome/browser/history/android/android_provider_backend.cc9
-rw-r--r--chrome/browser/history/android/android_provider_backend_unittest.cc18
-rw-r--r--chrome/browser/history/android/favicon_sql_handler.cc10
4 files changed, 22 insertions, 25 deletions
diff --git a/chrome/browser/history/android/android_history_types.h b/chrome/browser/history/android/android_history_types.h
index 843f465..ea56399 100644
--- a/chrome/browser/history/android/android_history_types.h
+++ b/chrome/browser/history/android/android_history_types.h
@@ -117,18 +117,14 @@ class HistoryAndBookmarkRow {
}
// The favicon related to page if any.
- void set_favicon(const scoped_refptr<base::RefCountedMemory>& data) {
+ void set_favicon(const std::vector<unsigned char>& data) {
set_value_explicitly(FAVICON);
favicon_ = data;
}
- const scoped_refptr<base::RefCountedMemory>& favicon() const {
+ const std::vector<unsigned char>& favicon() const {
return favicon_;
}
- bool favicon_valid() const {
- return favicon_.get() && favicon_->size();
- }
-
// The id of android url.
void set_id(AndroidURLID id) {
set_value_explicitly(ID);
@@ -172,7 +168,7 @@ class HistoryAndBookmarkRow {
string16 title_;
base::Time created_;
base::Time last_visit_time_;
- scoped_refptr<base::RefCountedMemory> favicon_;
+ std::vector<unsigned char> favicon_;
int visit_count_;
bool is_bookmark_;
int64 parent_id_;
diff --git a/chrome/browser/history/android/android_provider_backend.cc b/chrome/browser/history/android/android_provider_backend.cc
index 8957be6..fec1cdb 100644
--- a/chrome/browser/history/android/android_provider_backend.cc
+++ b/chrome/browser/history/android/android_provider_backend.cc
@@ -385,7 +385,7 @@ AndroidURLID AndroidProviderBackend::InsertHistoryAndBookmark(
scoped_ptr<FaviconChangeDetails> favicon;
if (row.is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON) &&
- row.favicon_valid()) {
+ !row.favicon().empty()) {
favicon.reset(new FaviconChangeDetails);
if (!favicon.get())
return false;
@@ -966,11 +966,10 @@ bool AndroidProviderBackend::SimulateUpdateURL(
FaviconID favicon_id = statement->statement()->ColumnInt64(4);
if (favicon_id) {
- scoped_refptr<base::RefCountedBytes> favicon = new base::RefCountedBytes();
- if (!thumbnail_db_->GetFavicon(favicon_id, NULL, &favicon->data(), NULL,
- NULL))
+ std::vector<unsigned char> favicon;
+ if (!thumbnail_db_->GetFavicon(favicon_id, NULL, &favicon, NULL, NULL))
return false;
- if (favicon->size())
+ if (!favicon.empty())
new_row.set_favicon(favicon);
favicon_details->urls.insert(old_url_row.url());
favicon_details->urls.insert(row.url());
diff --git a/chrome/browser/history/android/android_provider_backend_unittest.cc b/chrome/browser/history/android/android_provider_backend_unittest.cc
index 31a8462..7907ee0 100644
--- a/chrome/browser/history/android/android_provider_backend_unittest.cc
+++ b/chrome/browser/history/android/android_provider_backend_unittest.cc
@@ -497,7 +497,7 @@ TEST_F(AndroidProviderBackendTest, InsertHistoryAndBookmark) {
row2.set_title(UTF8ToUTF16("example"));
std::vector<unsigned char> data;
data.push_back('1');
- row2.set_favicon(base::RefCountedBytes::TakeVector(&data));
+ row2.set_favicon(data);
ASSERT_EQ(sql::INIT_OK, history_db_.Init(history_db_name_, bookmark_temp_));
ASSERT_EQ(sql::INIT_OK, thumbnail_db_.Init(thumbnail_db_name_, NULL,
@@ -606,7 +606,7 @@ TEST_F(AndroidProviderBackendTest, DeleteHistoryAndBookmarks) {
row2.set_title(UTF8ToUTF16("example"));
std::vector<unsigned char> data;
data.push_back('1');
- row2.set_favicon(base::RefCountedBytes::TakeVector(&data));
+ row2.set_favicon(data);
ASSERT_EQ(sql::INIT_OK, history_db_.Init(history_db_name_, bookmark_temp_));
ASSERT_EQ(sql::INIT_OK, thumbnail_db_.Init(thumbnail_db_name_, NULL,
@@ -795,7 +795,7 @@ TEST_F(AndroidProviderBackendTest, UpdateURL) {
row2.set_title(UTF8ToUTF16("example"));
std::vector<unsigned char> data;
data.push_back('1');
- row2.set_favicon(base::RefCountedBytes::TakeVector(&data));
+ row2.set_favicon(data);
ASSERT_EQ(sql::INIT_OK, history_db_.Init(history_db_name_, bookmark_temp_));
ASSERT_EQ(sql::INIT_OK, thumbnail_db_.Init(thumbnail_db_name_, NULL,
@@ -975,7 +975,7 @@ TEST_F(AndroidProviderBackendTest, UpdateVisitCount) {
row2.set_title(UTF8ToUTF16("example"));
std::vector<unsigned char> data;
data.push_back('1');
- row2.set_favicon(base::RefCountedBytes::TakeVector(&data));
+ row2.set_favicon(data);
ASSERT_EQ(sql::INIT_OK, history_db_.Init(history_db_name_, bookmark_temp_));
ASSERT_EQ(sql::INIT_OK, thumbnail_db_.Init(thumbnail_db_name_, NULL,
@@ -1056,7 +1056,7 @@ TEST_F(AndroidProviderBackendTest, UpdateLastVisitTime) {
row2.set_title(UTF8ToUTF16("example"));
std::vector<unsigned char> data;
data.push_back('1');
- row2.set_favicon(base::RefCountedBytes::TakeVector(&data));
+ row2.set_favicon(data);
ASSERT_EQ(sql::INIT_OK, history_db_.Init(history_db_name_, bookmark_temp_));
ASSERT_EQ(sql::INIT_OK, thumbnail_db_.Init(thumbnail_db_name_, NULL,
@@ -1138,7 +1138,7 @@ TEST_F(AndroidProviderBackendTest, UpdateFavicon) {
// Set favicon.
std::vector<unsigned char> data;
data.push_back('1');
- update_row1.set_favicon(base::RefCountedBytes::TakeVector(&data));
+ update_row1.set_favicon(data);
update_args.push_back(UTF8ToUTF16(row1.raw_url()));
delegate_.ResetDetails();
ASSERT_TRUE(backend->UpdateHistoryAndBookmarks(update_row1, "url = ?",
@@ -1164,7 +1164,7 @@ TEST_F(AndroidProviderBackendTest, UpdateFavicon) {
HistoryAndBookmarkRow update_row2;
// Set favicon.
- update_row1.set_favicon(new base::RefCountedBytes());
+ update_row1.set_favicon(std::vector<unsigned char>());
update_args.clear();
update_args.push_back(UTF8ToUTF16(row1.raw_url()));
delegate_.ResetDetails();
@@ -1561,7 +1561,7 @@ TEST_F(AndroidProviderBackendTest, DeleteHistory) {
row2.set_title(UTF8ToUTF16("example"));
std::vector<unsigned char> data;
data.push_back('1');
- row2.set_favicon(base::RefCountedBytes::TakeVector(&data));
+ row2.set_favicon(data);
ASSERT_EQ(sql::INIT_OK, history_db_.Init(history_db_name_, bookmark_temp_));
ASSERT_EQ(sql::INIT_OK, thumbnail_db_.Init(thumbnail_db_name_, NULL,
@@ -1728,7 +1728,7 @@ TEST_F(AndroidProviderBackendTest, AndroidCTSComplianceFolderColumnExists) {
row2.set_title(UTF8ToUTF16("example"));
std::vector<unsigned char> data;
data.push_back('1');
- row2.set_favicon(base::RefCountedBytes::TakeVector(&data));
+ row2.set_favicon(data);
AndroidURLID id1 = backend->InsertHistoryAndBookmark(row1);
ASSERT_TRUE(id1);
diff --git a/chrome/browser/history/android/favicon_sql_handler.cc b/chrome/browser/history/android/favicon_sql_handler.cc
index 0d68af5..b52aef4 100644
--- a/chrome/browser/history/android/favicon_sql_handler.cc
+++ b/chrome/browser/history/android/favicon_sql_handler.cc
@@ -32,14 +32,15 @@ FaviconSQLHandler::~FaviconSQLHandler() {
bool FaviconSQLHandler::Update(const HistoryAndBookmarkRow& row,
const TableIDRows& ids_set) {
FaviconID favicon_id = 0;
- if (row.favicon_valid()) {
+ if (!row.favicon().empty()) {
// If the image_data will be updated, it is not reasonable to find if the
// icon is already in database, just create a new favicon.
favicon_id = thumbnail_db_->AddFavicon(GURL(), history::FAVICON);
if (!favicon_id)
return false;
- scoped_refptr<base::RefCountedMemory> image_data = row.favicon();
+ scoped_refptr<base::RefCountedMemory> image_data =
+ new base::RefCountedBytes(row.favicon());
if (!thumbnail_db_->SetFavicon(favicon_id, image_data, Time::Now()))
return false;
}
@@ -104,7 +105,7 @@ bool FaviconSQLHandler::Delete(const TableIDRows& ids_set) {
bool FaviconSQLHandler::Insert(HistoryAndBookmarkRow* row) {
if (!row->is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON) ||
- !row->favicon_valid())
+ row->favicon().empty())
return true;
DCHECK(row->is_value_set_explicitly(HistoryAndBookmarkRow::URL));
@@ -114,7 +115,8 @@ bool FaviconSQLHandler::Insert(HistoryAndBookmarkRow* row) {
if (!id)
return false;
- scoped_refptr<base::RefCountedMemory> image_data = row->favicon();
+ scoped_refptr<base::RefCountedMemory> image_data =
+ new base::RefCountedBytes(row->favicon());
if (!thumbnail_db_->SetFavicon(id, image_data, Time::Now()))
return false;
return thumbnail_db_->AddIconMapping(row->url(), id);