| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/sync/glue/tab_node_pool.h" | 5 #include "chrome/browser/sync/glue/tab_node_pool.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 syncer::WriteNode tab_node(&trans); | 81 syncer::WriteNode tab_node(&trans); |
| 82 syncer::WriteNode::InitUniqueByCreationResult result = | 82 syncer::WriteNode::InitUniqueByCreationResult result = |
| 83 tab_node.InitUniqueByCreation(syncer::SESSIONS, root, tab_node_tag); | 83 tab_node.InitUniqueByCreation(syncer::SESSIONS, root, tab_node_tag); |
| 84 if (result != syncer::WriteNode::INIT_SUCCESS) { | 84 if (result != syncer::WriteNode::INIT_SUCCESS) { |
| 85 LOG(ERROR) << "Could not create new node with tag " | 85 LOG(ERROR) << "Could not create new node with tag " |
| 86 << tab_node_tag << "!"; | 86 << tab_node_tag << "!"; |
| 87 return kInvalidTabNodeID; | 87 return kInvalidTabNodeID; |
| 88 } | 88 } |
| 89 // We fill the new node with just enough data so that in case of a crash/bug | 89 // We fill the new node with just enough data so that in case of a crash/bug |
| 90 // we can identify the node as our own on re-association and reuse it. | 90 // we can identify the node as our own on re-association and reuse it. |
| 91 tab_node.SetTitle(UTF8ToWide(tab_node_tag)); | 91 tab_node.SetTitle(base::UTF8ToWide(tab_node_tag)); |
| 92 sync_pb::SessionSpecifics specifics; | 92 sync_pb::SessionSpecifics specifics; |
| 93 specifics.set_session_tag(machine_tag_); | 93 specifics.set_session_tag(machine_tag_); |
| 94 specifics.set_tab_node_id(tab_node_id); | 94 specifics.set_tab_node_id(tab_node_id); |
| 95 tab_node.SetSessionSpecifics(specifics); | 95 tab_node.SetSessionSpecifics(specifics); |
| 96 | 96 |
| 97 // Grow the pool by 1 since we created a new node. | 97 // Grow the pool by 1 since we created a new node. |
| 98 DVLOG(1) << "Adding sync node " << tab_node_id | 98 DVLOG(1) << "Adding sync node " << tab_node_id |
| 99 << " to tab node id pool"; | 99 << " to tab node id pool"; |
| 100 free_nodes_pool_.insert(tab_node_id); | 100 free_nodes_pool_.insert(tab_node_id); |
| 101 return tab_node_id; | 101 return tab_node_id; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 198 |
| 199 bool TabNodePool::Empty() const { return free_nodes_pool_.empty(); } | 199 bool TabNodePool::Empty() const { return free_nodes_pool_.empty(); } |
| 200 | 200 |
| 201 bool TabNodePool::Full() { return nodeid_tabid_map_.empty(); } | 201 bool TabNodePool::Full() { return nodeid_tabid_map_.empty(); } |
| 202 | 202 |
| 203 void TabNodePool::SetMachineTag(const std::string& machine_tag) { | 203 void TabNodePool::SetMachineTag(const std::string& machine_tag) { |
| 204 machine_tag_ = machine_tag; | 204 machine_tag_ = machine_tag; |
| 205 } | 205 } |
| 206 | 206 |
| 207 } // namespace browser_sync | 207 } // namespace browser_sync |
| OLD | NEW |