Commit 846191e5 authored by rfevang's avatar rfevang Committed by Commit bot

Dont set NEEDS_OFFLINE_PROCESSING flag.

The server will now always do processing for nodes that don't have
stars.id set, so no need to flip this flag any more.

BUG=

Review URL: https://codereview.chromium.org/888983002

Cr-Commit-Position: refs/heads/master@{#314900}
parent 62ae3a5d
......@@ -25,7 +25,6 @@ using bookmarks::BookmarkNode;
namespace {
const char* kBookmarkBarId = "f_bookmarks_bar";
const char* kFlagsKey = "stars.flags";
const char* kIdKey = "stars.id";
const char* kImageDataKey = "stars.imageData";
const char* kNoteKey = "stars.note";
......@@ -35,11 +34,6 @@ const char* kVersionKey = "stars.version";
const char* kBookmarkPrefix = "ebc_";
enum Flags {
// When set the server will attempt to fill in image and snippet information.
NEEDS_OFFLINE_PROCESSING = 0x1,
};
// Helper method for working with bookmark metainfo.
std::string DataForMetaInfoField(const BookmarkNode* node,
const std::string& field) {
......@@ -312,14 +306,6 @@ void EnhancedBookmarkModel::BookmarkNodeAdded(BookmarkModel* model,
if (node->GetMetaInfo(kIdKey, &remote_id)) {
AddToIdMap(node);
ScheduleResetDuplicateRemoteIds();
} else if (node->is_url()) {
set_needs_offline_processing_tasks_[node] =
make_linked_ptr(new base::CancelableClosure(
base::Bind(&EnhancedBookmarkModel::SetNeedsOfflineProcessing,
weak_ptr_factory_.GetWeakPtr(),
base::Unretained(node))));
base::MessageLoopProxy::current()->PostTask(
FROM_HERE, set_needs_offline_processing_tasks_[node]->callback());
}
FOR_EACH_OBSERVER(
EnhancedBookmarkModelObserver, observers_, EnhancedBookmarkAdded(node));
......@@ -408,7 +394,6 @@ void EnhancedBookmarkModel::RemoveNodeFromMaps(const BookmarkNode* node) {
std::string remote_id = GetRemoteId(node);
id_map_.erase(remote_id);
nodes_to_reset_.erase(node);
set_needs_offline_processing_tasks_.erase(node);
}
void EnhancedBookmarkModel::ScheduleResetDuplicateRemoteIds() {
......@@ -432,19 +417,6 @@ void EnhancedBookmarkModel::ResetDuplicateRemoteIds() {
nodes_to_reset_.clear();
}
void EnhancedBookmarkModel::SetNeedsOfflineProcessing(
const BookmarkNode* node) {
set_needs_offline_processing_tasks_.erase(node);
int flags = 0;
std::string flags_str;
if (node->GetMetaInfo(kFlagsKey, &flags_str)) {
if (!base::StringToInt(flags_str, &flags))
flags = 0;
}
flags |= NEEDS_OFFLINE_PROCESSING;
SetMetaInfo(node, kFlagsKey, base::IntToString(flags));
}
void EnhancedBookmarkModel::SetMetaInfo(const BookmarkNode* node,
const std::string& field,
const std::string& value) {
......
......@@ -187,9 +187,6 @@ class EnhancedBookmarkModel : public KeyedService,
// Clears out any duplicate remote ids detected by AddToIdMap calls.
void ResetDuplicateRemoteIds();
// Sets the NEEDS_OFFLINE_PROCESSING flag on the given node.
void SetNeedsOfflineProcessing(const bookmarks::BookmarkNode* node);
// Helper method for setting a meta info field on a node. Also updates the
// version field.
void SetMetaInfo(const bookmarks::BookmarkNode* node,
......@@ -210,11 +207,6 @@ class EnhancedBookmarkModel : public KeyedService,
IdToNodeMap id_map_;
NodeToIdMap nodes_to_reset_;
// Pending SetNeedsOfflineProcessing calls are stored here, as they may need
// to be cancelled if the node is removed.
std::map<const bookmarks::BookmarkNode*, linked_ptr<base::CancelableClosure>>
set_needs_offline_processing_tasks_;
// Caches the remote id of a node before its meta info changes.
std::string prev_remote_id_;
......
......@@ -679,85 +679,6 @@ TEST_F(EnhancedBookmarkModelTest, NodeRemovedWhileResetDuplicationScheduled) {
base::RunLoop().RunUntilIdle();
}
// Verifies that the NEEDS_OFFLINE_PROCESSING flag is set for nodes added
// with no remote id.
TEST_F(EnhancedBookmarkModelTest, BookmarkAddedSetsOfflineProcessingFlag) {
const BookmarkNode* node =
bookmark_model_->AddURL(bookmark_model_->other_node(),
0,
base::ASCIIToUTF16("Some title"),
GURL(BOOKMARK_URL));
std::string flags_str;
EXPECT_FALSE(node->GetMetaInfo("stars.flags", &flags_str));
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(node->GetMetaInfo("stars.flags", &flags_str));
int flags;
ASSERT_TRUE(base::StringToInt(flags_str, &flags));
EXPECT_EQ(1, (flags & 1));
}
// Verifies that the NEEDS_OFFLINE_PROCESSING_FLAG is not set for added folders.
TEST_F(EnhancedBookmarkModelTest, FolderAddedDoesNotSetOfflineProcessingFlag) {
const BookmarkNode* node = AddFolder();
base::RunLoop().RunUntilIdle();
std::string flags_str;
if (node->GetMetaInfo("stars.flags", &flags_str)) {
int flags;
ASSERT_TRUE(base::StringToInt(flags_str, &flags));
EXPECT_EQ(0, (flags & 1));
}
}
// Verifies that when a bookmark is added that has a remote id, the status of
// the NEEDS_OFFLINE_PROCESSING flag doesn't change.
TEST_F(EnhancedBookmarkModelTest,
BookmarkAddedWithIdKeepsOfflineProcessingFlag) {
BookmarkNode::MetaInfoMap meta_info;
meta_info["stars.id"] = "some_id";
meta_info["stars.flags"] = "1";
const BookmarkNode* node1 =
bookmark_model_->AddURLWithCreationTimeAndMetaInfo(
bookmark_model_->other_node(),
0,
base::ASCIIToUTF16("Some title"),
GURL(BOOKMARK_URL),
base::Time::Now(),
&meta_info);
base::RunLoop().RunUntilIdle();
std::string flags_str;
ASSERT_TRUE(node1->GetMetaInfo("stars.flags", &flags_str));
int flags;
ASSERT_TRUE(base::StringToInt(flags_str, &flags));
EXPECT_EQ(1, (flags & 1));
meta_info["stars.flags"] = "0";
const BookmarkNode* node2 =
bookmark_model_->AddURLWithCreationTimeAndMetaInfo(
bookmark_model_->other_node(),
0,
base::ASCIIToUTF16("Some title"),
GURL(BOOKMARK_URL),
base::Time::Now(),
&meta_info);
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(node2->GetMetaInfo("stars.flags", &flags_str));
ASSERT_TRUE(base::StringToInt(flags_str, &flags));
EXPECT_EQ(0, (flags & 1));
}
TEST_F(EnhancedBookmarkModelTest,
NodeRemovedWhileSetNeedsOfflineProcessingIsScheduled) {
const BookmarkNode* node =
bookmark_model_->AddURL(bookmark_model_->other_node(),
0,
base::ASCIIToUTF16("Some title"),
GURL(BOOKMARK_URL));
bookmark_model_->Remove(node->parent(), node->parent()->GetIndexOf(node));
base::RunLoop().RunUntilIdle();
}
TEST_F(EnhancedBookmarkModelTest,
RemoveParentShouldRemoveChildrenFromMaps) {
const BookmarkNode* parent = AddFolder();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment