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

Side by Side Diff: chrome/browser/sync/internal_api/base_node.cc

Issue 7977034: Revert 102184 - [Sync] use base::Time in sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/internal_api/base_node.h" 5 #include "chrome/browser/sync/internal_api/base_node.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/sha1.h" 8 #include "base/sha1.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/sync/engine/syncapi_internal.h" 12 #include "chrome/browser/sync/engine/syncapi_internal.h"
13 #include "chrome/browser/sync/internal_api/base_transaction.h" 13 #include "chrome/browser/sync/internal_api/base_transaction.h"
14 #include "chrome/browser/sync/protocol/app_specifics.pb.h" 14 #include "chrome/browser/sync/protocol/app_specifics.pb.h"
15 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" 15 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h"
16 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" 16 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
17 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" 17 #include "chrome/browser/sync/protocol/extension_specifics.pb.h"
18 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h" 18 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h"
19 #include "chrome/browser/sync/protocol/password_specifics.pb.h" 19 #include "chrome/browser/sync/protocol/password_specifics.pb.h"
20 #include "chrome/browser/sync/protocol/session_specifics.pb.h" 20 #include "chrome/browser/sync/protocol/session_specifics.pb.h"
21 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" 21 #include "chrome/browser/sync/protocol/theme_specifics.pb.h"
22 #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h" 22 #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h"
23 #include "chrome/browser/sync/syncable/directory_manager.h" 23 #include "chrome/browser/sync/syncable/directory_manager.h"
24 #include "chrome/browser/sync/syncable/syncable.h" 24 #include "chrome/browser/sync/syncable/syncable.h"
25 #include "chrome/browser/sync/syncable/syncable_id.h" 25 #include "chrome/browser/sync/syncable/syncable_id.h"
26 #include "chrome/browser/sync/util/time.h"
27 26
28 using syncable::SPECIFICS; 27 using syncable::SPECIFICS;
29 using sync_pb::AutofillProfileSpecifics; 28 using sync_pb::AutofillProfileSpecifics;
30 29
31 namespace sync_api { 30 namespace sync_api {
32 31
33 // Helper function to look up the int64 metahandle of an object given the ID 32 // Helper function to look up the int64 metahandle of an object given the ID
34 // string. 33 // string.
35 static int64 IdToMetahandle(syncable::BaseTransaction* trans, 34 static int64 IdToMetahandle(syncable::BaseTransaction* trans,
36 const syncable::Id& id) { 35 const syncable::Id& id) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 167
169 int64 BaseNode::GetParentId() const { 168 int64 BaseNode::GetParentId() const {
170 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), 169 return IdToMetahandle(GetTransaction()->GetWrappedTrans(),
171 GetEntry()->Get(syncable::PARENT_ID)); 170 GetEntry()->Get(syncable::PARENT_ID));
172 } 171 }
173 172
174 int64 BaseNode::GetId() const { 173 int64 BaseNode::GetId() const {
175 return GetEntry()->Get(syncable::META_HANDLE); 174 return GetEntry()->Get(syncable::META_HANDLE);
176 } 175 }
177 176
178 const base::Time& BaseNode::GetModificationTime() const { 177 int64 BaseNode::GetModificationTime() const {
179 return GetEntry()->Get(syncable::MTIME); 178 return GetEntry()->Get(syncable::MTIME);
180 } 179 }
181 180
182 bool BaseNode::GetIsFolder() const { 181 bool BaseNode::GetIsFolder() const {
183 return GetEntry()->Get(syncable::IS_DIR); 182 return GetEntry()->Get(syncable::IS_DIR);
184 } 183 }
185 184
186 std::string BaseNode::GetTitle() const { 185 std::string BaseNode::GetTitle() const {
187 std::string result; 186 std::string result;
188 // TODO(zea): refactor bookmarks to not need this functionality. 187 // TODO(zea): refactor bookmarks to not need this functionality.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 DictionaryValue* node_info = new DictionaryValue(); 228 DictionaryValue* node_info = new DictionaryValue();
230 node_info->SetString("id", base::Int64ToString(GetId())); 229 node_info->SetString("id", base::Int64ToString(GetId()));
231 node_info->SetBoolean("isFolder", GetIsFolder()); 230 node_info->SetBoolean("isFolder", GetIsFolder());
232 node_info->SetString("title", GetTitle()); 231 node_info->SetString("title", GetTitle());
233 node_info->Set("type", ModelTypeToValue(GetModelType())); 232 node_info->Set("type", ModelTypeToValue(GetModelType()));
234 return node_info; 233 return node_info;
235 } 234 }
236 235
237 DictionaryValue* BaseNode::GetDetailsAsValue() const { 236 DictionaryValue* BaseNode::GetDetailsAsValue() const {
238 DictionaryValue* node_info = GetSummaryAsValue(); 237 DictionaryValue* node_info = GetSummaryAsValue();
239 node_info->SetString( 238 // TODO(akalin): Return time in a better format.
240 "modificationTime", 239 node_info->SetString("modificationTime",
241 browser_sync::GetTimeDebugString(GetModificationTime())); 240 base::Int64ToString(GetModificationTime()));
242 node_info->SetString("parentId", base::Int64ToString(GetParentId())); 241 node_info->SetString("parentId", base::Int64ToString(GetParentId()));
243 // Specifics are already in the Entry value, so no need to duplicate 242 // Specifics are already in the Entry value, so no need to duplicate
244 // it here. 243 // it here.
245 node_info->SetString("externalId", 244 node_info->SetString("externalId",
246 base::Int64ToString(GetExternalId())); 245 base::Int64ToString(GetExternalId()));
247 node_info->SetString("predecessorId", 246 node_info->SetString("predecessorId",
248 base::Int64ToString(GetPredecessorId())); 247 base::Int64ToString(GetPredecessorId()));
249 node_info->SetString("successorId", 248 node_info->SetString("successorId",
250 base::Int64ToString(GetSuccessorId())); 249 base::Int64ToString(GetSuccessorId()));
251 node_info->SetString("firstChildId", 250 node_info->SetString("firstChildId",
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 const sync_pb::EntitySpecifics& specifics) { 328 const sync_pb::EntitySpecifics& specifics) {
330 syncable::ModelType type = syncable::GetModelTypeFromSpecifics(specifics); 329 syncable::ModelType type = syncable::GetModelTypeFromSpecifics(specifics);
331 DCHECK_NE(syncable::UNSPECIFIED, type); 330 DCHECK_NE(syncable::UNSPECIFIED, type);
332 if (GetModelType() != syncable::UNSPECIFIED) { 331 if (GetModelType() != syncable::UNSPECIFIED) {
333 DCHECK_EQ(GetModelType(), type); 332 DCHECK_EQ(GetModelType(), type);
334 } 333 }
335 unencrypted_data_.CopyFrom(specifics); 334 unencrypted_data_.CopyFrom(specifics);
336 } 335 }
337 336
338 } // namespace sync_api 337 } // namespace sync_api
OLDNEW
« no previous file with comments | « chrome/browser/sync/internal_api/base_node.h ('k') | chrome/browser/sync/internal_api/syncapi_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698