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

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

Issue 7981006: [Sync] use base::Time in sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win compile error 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/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/sync/engine/syncapi_internal.h" 11 #include "chrome/browser/sync/engine/syncapi_internal.h"
12 #include "chrome/browser/sync/internal_api/base_transaction.h" 12 #include "chrome/browser/sync/internal_api/base_transaction.h"
13 #include "chrome/browser/sync/protocol/app_specifics.pb.h" 13 #include "chrome/browser/sync/protocol/app_specifics.pb.h"
14 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" 14 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h"
15 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" 15 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
16 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" 16 #include "chrome/browser/sync/protocol/extension_specifics.pb.h"
17 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h" 17 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h"
18 #include "chrome/browser/sync/protocol/password_specifics.pb.h" 18 #include "chrome/browser/sync/protocol/password_specifics.pb.h"
19 #include "chrome/browser/sync/protocol/session_specifics.pb.h" 19 #include "chrome/browser/sync/protocol/session_specifics.pb.h"
20 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" 20 #include "chrome/browser/sync/protocol/theme_specifics.pb.h"
21 #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h" 21 #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h"
22 #include "chrome/browser/sync/syncable/directory_manager.h" 22 #include "chrome/browser/sync/syncable/directory_manager.h"
23 #include "chrome/browser/sync/syncable/syncable.h" 23 #include "chrome/browser/sync/syncable/syncable.h"
24 #include "chrome/browser/sync/syncable/syncable_id.h" 24 #include "chrome/browser/sync/syncable/syncable_id.h"
25 #include "chrome/browser/sync/util/time.h"
25 26
26 using syncable::SPECIFICS; 27 using syncable::SPECIFICS;
27 using sync_pb::AutofillProfileSpecifics; 28 using sync_pb::AutofillProfileSpecifics;
28 29
29 namespace sync_api { 30 namespace sync_api {
30 31
31 // 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
32 // string. 33 // string.
33 static int64 IdToMetahandle(syncable::BaseTransaction* trans, 34 static int64 IdToMetahandle(syncable::BaseTransaction* trans,
34 const syncable::Id& id) { 35 const syncable::Id& id) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 164
164 int64 BaseNode::GetParentId() const { 165 int64 BaseNode::GetParentId() const {
165 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), 166 return IdToMetahandle(GetTransaction()->GetWrappedTrans(),
166 GetEntry()->Get(syncable::PARENT_ID)); 167 GetEntry()->Get(syncable::PARENT_ID));
167 } 168 }
168 169
169 int64 BaseNode::GetId() const { 170 int64 BaseNode::GetId() const {
170 return GetEntry()->Get(syncable::META_HANDLE); 171 return GetEntry()->Get(syncable::META_HANDLE);
171 } 172 }
172 173
173 int64 BaseNode::GetModificationTime() const { 174 const base::Time& BaseNode::GetModificationTime() const {
174 return GetEntry()->Get(syncable::MTIME); 175 return GetEntry()->Get(syncable::MTIME);
175 } 176 }
176 177
177 bool BaseNode::GetIsFolder() const { 178 bool BaseNode::GetIsFolder() const {
178 return GetEntry()->Get(syncable::IS_DIR); 179 return GetEntry()->Get(syncable::IS_DIR);
179 } 180 }
180 181
181 std::string BaseNode::GetTitle() const { 182 std::string BaseNode::GetTitle() const {
182 std::string result; 183 std::string result;
183 // TODO(zea): refactor bookmarks to not need this functionality. 184 // TODO(zea): refactor bookmarks to not need this functionality.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 DictionaryValue* node_info = new DictionaryValue(); 225 DictionaryValue* node_info = new DictionaryValue();
225 node_info->SetString("id", base::Int64ToString(GetId())); 226 node_info->SetString("id", base::Int64ToString(GetId()));
226 node_info->SetBoolean("isFolder", GetIsFolder()); 227 node_info->SetBoolean("isFolder", GetIsFolder());
227 node_info->SetString("title", GetTitle()); 228 node_info->SetString("title", GetTitle());
228 node_info->Set("type", ModelTypeToValue(GetModelType())); 229 node_info->Set("type", ModelTypeToValue(GetModelType()));
229 return node_info; 230 return node_info;
230 } 231 }
231 232
232 DictionaryValue* BaseNode::GetDetailsAsValue() const { 233 DictionaryValue* BaseNode::GetDetailsAsValue() const {
233 DictionaryValue* node_info = GetSummaryAsValue(); 234 DictionaryValue* node_info = GetSummaryAsValue();
234 // TODO(akalin): Return time in a better format. 235 node_info->SetString(
235 node_info->SetString("modificationTime", 236 "modificationTime",
236 base::Int64ToString(GetModificationTime())); 237 browser_sync::GetTimeDebugString(GetModificationTime()));
237 node_info->SetString("parentId", base::Int64ToString(GetParentId())); 238 node_info->SetString("parentId", base::Int64ToString(GetParentId()));
238 // Specifics are already in the Entry value, so no need to duplicate 239 // Specifics are already in the Entry value, so no need to duplicate
239 // it here. 240 // it here.
240 node_info->SetString("externalId", 241 node_info->SetString("externalId",
241 base::Int64ToString(GetExternalId())); 242 base::Int64ToString(GetExternalId()));
242 node_info->SetString("predecessorId", 243 node_info->SetString("predecessorId",
243 base::Int64ToString(GetPredecessorId())); 244 base::Int64ToString(GetPredecessorId()));
244 node_info->SetString("successorId", 245 node_info->SetString("successorId",
245 base::Int64ToString(GetSuccessorId())); 246 base::Int64ToString(GetSuccessorId()));
246 node_info->SetString("firstChildId", 247 node_info->SetString("firstChildId",
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 const sync_pb::EntitySpecifics& specifics) { 325 const sync_pb::EntitySpecifics& specifics) {
325 syncable::ModelType type = syncable::GetModelTypeFromSpecifics(specifics); 326 syncable::ModelType type = syncable::GetModelTypeFromSpecifics(specifics);
326 DCHECK_NE(syncable::UNSPECIFIED, type); 327 DCHECK_NE(syncable::UNSPECIFIED, type);
327 if (GetModelType() != syncable::UNSPECIFIED) { 328 if (GetModelType() != syncable::UNSPECIFIED) {
328 DCHECK_EQ(GetModelType(), type); 329 DCHECK_EQ(GetModelType(), type);
329 } 330 }
330 unencrypted_data_.CopyFrom(specifics); 331 unencrypted_data_.CopyFrom(specifics);
331 } 332 }
332 333
333 } // namespace sync_api 334 } // namespace sync_api
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698