Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: chrome/browser/sync/glue/tab_node_pool.cc

Issue 12314090: Add utf_string_conversions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 syncer::WriteNode tab_node(&trans); 56 syncer::WriteNode tab_node(&trans);
57 syncer::WriteNode::InitUniqueByCreationResult result = 57 syncer::WriteNode::InitUniqueByCreationResult result =
58 tab_node.InitUniqueByCreation(syncer::SESSIONS, root, tab_node_tag); 58 tab_node.InitUniqueByCreation(syncer::SESSIONS, root, tab_node_tag);
59 if (result != syncer::WriteNode::INIT_SUCCESS) { 59 if (result != syncer::WriteNode::INIT_SUCCESS) {
60 LOG(ERROR) << "Could not create new node with tag " 60 LOG(ERROR) << "Could not create new node with tag "
61 << tab_node_tag << "!"; 61 << tab_node_tag << "!";
62 return syncer::kInvalidId; 62 return syncer::kInvalidId;
63 } 63 }
64 // We fill the new node with just enough data so that in case of a crash/bug 64 // We fill the new node with just enough data so that in case of a crash/bug
65 // we can identify the node as our own on re-association and reuse it. 65 // we can identify the node as our own on re-association and reuse it.
66 tab_node.SetTitle(UTF8ToWide(tab_node_tag)); 66 tab_node.SetTitle(base::UTF8ToWide(tab_node_tag));
67 sync_pb::SessionSpecifics specifics; 67 sync_pb::SessionSpecifics specifics;
68 specifics.set_session_tag(machine_tag_); 68 specifics.set_session_tag(machine_tag_);
69 specifics.set_tab_node_id(tab_node_id); 69 specifics.set_tab_node_id(tab_node_id);
70 tab_node.SetSessionSpecifics(specifics); 70 tab_node.SetSessionSpecifics(specifics);
71 71
72 // Grow the pool by 1 since we created a new node. We don't actually need 72 // Grow the pool by 1 since we created a new node. We don't actually need
73 // to put the node's id in the pool now, since the pool is still empty. 73 // to put the node's id in the pool now, since the pool is still empty.
74 // The id will be added when that tab is closed and the node is freed. 74 // The id will be added when that tab is closed and the node is freed.
75 tab_syncid_pool_.resize(tab_node_id + 1); 75 tab_syncid_pool_.resize(tab_node_id + 1);
76 DVLOG(1) << "Adding sync node " 76 DVLOG(1) << "Adding sync node "
77 << tab_node.GetId() << " to tab syncid pool"; 77 << tab_node.GetId() << " to tab syncid pool";
78 return tab_node.GetId(); 78 return tab_node.GetId();
79 } else { 79 } else {
80 // There are nodes available, grab next free and decrement free pointer. 80 // There are nodes available, grab next free and decrement free pointer.
81 return tab_syncid_pool_[static_cast<size_t>(tab_pool_fp_--)]; 81 return tab_syncid_pool_[static_cast<size_t>(tab_pool_fp_--)];
82 } 82 }
83 } 83 }
84 84
85 void TabNodePool::FreeTabNode(int64 sync_id) { 85 void TabNodePool::FreeTabNode(int64 sync_id) {
86 // Pool size should always match # of free tab nodes. 86 // Pool size should always match # of free tab nodes.
87 DCHECK_LT(tab_pool_fp_, static_cast<int64>(tab_syncid_pool_.size())); 87 DCHECK_LT(tab_pool_fp_, static_cast<int64>(tab_syncid_pool_.size()));
88 tab_syncid_pool_[static_cast<size_t>(++tab_pool_fp_)] = sync_id; 88 tab_syncid_pool_[static_cast<size_t>(++tab_pool_fp_)] = sync_id;
89 } 89 }
90 90
91 } // namespace browser_sync 91 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/synced_device_tracker.cc ('k') | chrome/browser/sync/glue/typed_url_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698