summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-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, 25 insertions, 22 deletions
diff --git a/chrome/browser/history/android/android_history_types.h b/chrome/browser/history/android/android_history_types.h
index ea56399..843f465 100644
--- a/chrome/browser/history/android/android_history_types.h
+++ b/chrome/browser/history/android/android_history_types.h
@@ -117,14 +117,18 @@ class HistoryAndBookmarkRow {
}
// The favicon related to page if any.
- void set_favicon(const std::vector<unsigned char>& data) {
+ void set_favicon(const scoped_refptr<base::RefCountedMemory>& data) {
set_value_explicitly(FAVICON);
favicon_ = data;
}
- const std::vector<unsigned char>& favicon() const {
+ const scoped_refptr<base::RefCountedMemory>& 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);
@@ -168,7 +172,7 @@ class HistoryAndBookmarkRow {
string16 title_;
base::Time created_;
base::Time last_visit_time_;
- std::vector<unsigned char> favicon_;
+ scoped_refptr<base::RefCountedMemory> 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 fec1cdb..8957be6 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().empty()) {
+ row.favicon_valid()) {
favicon.reset(new FaviconChangeDetails);
if (!favicon.get())
return false;
@@ -966,10 +966,11 @@ bool AndroidProviderBackend::SimulateUpdateURL(
FaviconID favicon_id = statement->statement()->ColumnInt64(4);
if (favicon_id) {
- std::vector<unsigned char> favicon;
- if (!thumbnail_db_->GetFavicon(favicon_id, NULL, &favicon, NULL, NULL))
+ scoped_refptr<base::RefCountedBytes> favicon = new base::RefCountedBytes();
+ if (!thumbnail_db_->GetFavicon(favicon_id, NULL, &favicon->data(), NULL,
+ NULL))
return false;
- if (!favicon.empty())
+ if (favicon->size())
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 7907ee0..31a8462 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(data);
+ row2.set_favicon(base::RefCountedBytes::TakeVector(&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(data);
+ row2.set_favicon(base::RefCountedBytes::TakeVector(&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(data);
+ row2.set_favicon(base::RefCountedBytes::TakeVector(&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(data);
+ row2.set_favicon(base::RefCountedBytes::TakeVector(&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(data);
+ row2.set_favicon(base::RefCountedBytes::TakeVector(&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(data);
+ update_row1.set_favicon(base::RefCountedBytes::TakeVector(&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(std::vector<unsigned char>());
+ update_row1.set_favicon(new base::RefCountedBytes());
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(data);
+ row2.set_favicon(base::RefCountedBytes::TakeVector(&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(data);
+ row2.set_favicon(base::RefCountedBytes::TakeVector(&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 b52aef4..0d68af5 100644
--- a/chrome/browser/history/android/favicon_sql_handler.cc
+++ b/chrome/browser/history/android/favicon_sql_handler.cc
@@ -32,15 +32,14 @@ FaviconSQLHandler::~FaviconSQLHandler() {
bool FaviconSQLHandler::Update(const HistoryAndBookmarkRow& row,
const TableIDRows& ids_set) {
FaviconID favicon_id = 0;
- if (!row.favicon().empty()) {
+ if (row.favicon_valid()) {
// 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 =
- new base::RefCountedBytes(row.favicon());
+ scoped_refptr<base::RefCountedMemory> image_data = row.favicon();
if (!thumbnail_db_->SetFavicon(favicon_id, image_data, Time::Now()))
return false;
}
@@ -105,7 +104,7 @@ bool FaviconSQLHandler::Delete(const TableIDRows& ids_set) {
bool FaviconSQLHandler::Insert(HistoryAndBookmarkRow* row) {
if (!row->is_value_set_explicitly(HistoryAndBookmarkRow::FAVICON) ||
- row->favicon().empty())
+ !row->favicon_valid())
return true;
DCHECK(row->is_value_set_explicitly(HistoryAndBookmarkRow::URL));
@@ -115,8 +114,7 @@ bool FaviconSQLHandler::Insert(HistoryAndBookmarkRow* row) {
if (!id)
return false;
- scoped_refptr<base::RefCountedMemory> image_data =
- new base::RefCountedBytes(row->favicon());
+ scoped_refptr<base::RefCountedMemory> image_data = row->favicon();
if (!thumbnail_db_->SetFavicon(id, image_data, Time::Now()))
return false;
return thumbnail_db_->AddIconMapping(row->url(), id);