OLD | NEW |
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/syncable/syncable.h" | 5 #include "chrome/browser/sync/syncable/syncable.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "base/logging.h" | 32 #include "base/logging.h" |
33 #include "base/memory/scoped_ptr.h" | 33 #include "base/memory/scoped_ptr.h" |
34 #include "base/perftimer.h" | 34 #include "base/perftimer.h" |
35 #include "base/string_number_conversions.h" | 35 #include "base/string_number_conversions.h" |
36 #include "base/string_util.h" | 36 #include "base/string_util.h" |
37 #include "base/stl_util.h" | 37 #include "base/stl_util.h" |
38 #include "base/time.h" | 38 #include "base/time.h" |
39 #include "base/tracked.h" | 39 #include "base/tracked.h" |
40 #include "base/utf_string_conversions.h" | 40 #include "base/utf_string_conversions.h" |
41 #include "base/values.h" | 41 #include "base/values.h" |
42 #include "chrome/browser/sync/engine/syncer.h" | |
43 #include "chrome/browser/sync/engine/syncer_util.h" | |
44 #include "chrome/browser/sync/protocol/proto_value_conversions.h" | 42 #include "chrome/browser/sync/protocol/proto_value_conversions.h" |
45 #include "chrome/browser/sync/protocol/service_constants.h" | 43 #include "chrome/browser/sync/protocol/service_constants.h" |
46 #include "chrome/browser/sync/syncable/directory_backing_store.h" | 44 #include "chrome/browser/sync/syncable/directory_backing_store.h" |
47 #include "chrome/browser/sync/syncable/directory_change_delegate.h" | 45 #include "chrome/browser/sync/syncable/directory_change_delegate.h" |
48 #include "chrome/browser/sync/syncable/directory_manager.h" | 46 #include "chrome/browser/sync/syncable/directory_manager.h" |
49 #include "chrome/browser/sync/syncable/model_type.h" | 47 #include "chrome/browser/sync/syncable/model_type.h" |
50 #include "chrome/browser/sync/syncable/syncable-inl.h" | 48 #include "chrome/browser/sync/syncable/syncable-inl.h" |
51 #include "chrome/browser/sync/syncable/syncable_changes_version.h" | 49 #include "chrome/browser/sync/syncable/syncable_changes_version.h" |
52 #include "chrome/browser/sync/syncable/syncable_columns.h" | 50 #include "chrome/browser/sync/syncable/syncable_columns.h" |
53 #include "chrome/browser/sync/syncable/syncable_enum_conversions.h" | 51 #include "chrome/browser/sync/syncable/syncable_enum_conversions.h" |
54 #include "chrome/browser/sync/syncable/transaction_observer.h" | 52 #include "chrome/browser/sync/syncable/transaction_observer.h" |
55 #include "chrome/browser/sync/util/logging.h" | 53 #include "chrome/browser/sync/util/logging.h" |
56 #include "chrome/common/deprecated/event_sys-inl.h" | |
57 #include "net/base/escape.h" | 54 #include "net/base/escape.h" |
58 | 55 |
59 namespace { | 56 namespace { |
60 enum InvariantCheckLevel { | 57 enum InvariantCheckLevel { |
61 OFF = 0, | 58 OFF = 0, |
62 VERIFY_IN_MEMORY = 1, | 59 VERIFY_IN_MEMORY = 1, |
63 FULL_DB_VERIFICATION = 2 | 60 FULL_DB_VERIFICATION = 2 |
64 }; | 61 }; |
65 | 62 |
66 static const InvariantCheckLevel kInvariantCheckLevel = VERIFY_IN_MEMORY; | 63 static const InvariantCheckLevel kInvariantCheckLevel = VERIFY_IN_MEMORY; |
67 | 64 |
68 // Max number of milliseconds to spend checking syncable entry invariants | 65 // Max number of milliseconds to spend checking syncable entry invariants |
69 static const int kInvariantCheckMaxMs = 50; | 66 static const int kInvariantCheckMaxMs = 50; |
70 } // namespace | 67 } // namespace |
71 | 68 |
72 using browser_sync::SyncerUtil; | |
73 using std::string; | 69 using std::string; |
74 | 70 |
75 | 71 |
76 namespace syncable { | 72 namespace syncable { |
77 | 73 |
78 #define ENUM_CASE(x) case x: return #x; break | 74 #define ENUM_CASE(x) case x: return #x; break |
79 | 75 |
80 std::string WriterTagToString(WriterTag writer_tag) { | 76 std::string WriterTagToString(WriterTag writer_tag) { |
81 switch (writer_tag) { | 77 switch (writer_tag) { |
82 ENUM_CASE(INVALID); | 78 ENUM_CASE(INVALID); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 refcount(1), | 376 refcount(1), |
381 name(name), | 377 name(name), |
382 metahandles_index(new Directory::MetahandlesIndex), | 378 metahandles_index(new Directory::MetahandlesIndex), |
383 ids_index(new Directory::IdsIndex), | 379 ids_index(new Directory::IdsIndex), |
384 parent_id_child_index(new Directory::ParentIdChildIndex), | 380 parent_id_child_index(new Directory::ParentIdChildIndex), |
385 client_tag_index(new Directory::ClientTagIndex), | 381 client_tag_index(new Directory::ClientTagIndex), |
386 unapplied_update_metahandles(new MetahandleSet), | 382 unapplied_update_metahandles(new MetahandleSet), |
387 unsynced_metahandles(new MetahandleSet), | 383 unsynced_metahandles(new MetahandleSet), |
388 dirty_metahandles(new MetahandleSet), | 384 dirty_metahandles(new MetahandleSet), |
389 metahandles_to_purge(new MetahandleSet), | 385 metahandles_to_purge(new MetahandleSet), |
390 channel(new Directory::Channel(syncable::DIRECTORY_DESTROYED)), | |
391 info_status(Directory::KERNEL_SHARE_INFO_VALID), | 386 info_status(Directory::KERNEL_SHARE_INFO_VALID), |
392 persisted_info(info.kernel_info), | 387 persisted_info(info.kernel_info), |
393 cache_guid(info.cache_guid), | 388 cache_guid(info.cache_guid), |
394 next_metahandle(info.max_metahandle + 1), | 389 next_metahandle(info.max_metahandle + 1), |
395 delegate(delegate), | 390 delegate(delegate), |
396 observers(new ObserverListThreadSafe<TransactionObserver>()) { | 391 observers(new ObserverListThreadSafe<TransactionObserver>()) { |
397 DCHECK(delegate); | 392 DCHECK(delegate); |
398 } | 393 } |
399 | 394 |
400 void Directory::Kernel::AddRef() { | 395 void Directory::Kernel::AddRef() { |
401 base::subtle::NoBarrier_AtomicIncrement(&refcount, 1); | 396 base::subtle::NoBarrier_AtomicIncrement(&refcount, 1); |
402 } | 397 } |
403 | 398 |
404 void Directory::Kernel::Release() { | 399 void Directory::Kernel::Release() { |
405 if (!base::subtle::NoBarrier_AtomicIncrement(&refcount, -1)) | 400 if (!base::subtle::NoBarrier_AtomicIncrement(&refcount, -1)) |
406 delete this; | 401 delete this; |
407 } | 402 } |
408 | 403 |
409 Directory::Kernel::~Kernel() { | 404 Directory::Kernel::~Kernel() { |
410 CHECK_EQ(0, refcount); | 405 CHECK_EQ(0, refcount); |
411 delete channel; | |
412 delete unsynced_metahandles; | 406 delete unsynced_metahandles; |
413 delete unapplied_update_metahandles; | 407 delete unapplied_update_metahandles; |
414 delete dirty_metahandles; | 408 delete dirty_metahandles; |
415 delete metahandles_to_purge; | 409 delete metahandles_to_purge; |
416 delete parent_id_child_index; | 410 delete parent_id_child_index; |
417 delete client_tag_index; | 411 delete client_tag_index; |
418 delete ids_index; | 412 delete ids_index; |
419 STLDeleteElements(metahandles_index); | 413 STLDeleteElements(metahandles_index); |
420 delete metahandles_index; | 414 delete metahandles_index; |
421 } | 415 } |
(...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1946 CHECK(result); | 1940 CHECK(result); |
1947 for (iterator i = GetParentChildIndexLowerBound(lock, parent_id), | 1941 for (iterator i = GetParentChildIndexLowerBound(lock, parent_id), |
1948 end = GetParentChildIndexUpperBound(lock, parent_id); | 1942 end = GetParentChildIndexUpperBound(lock, parent_id); |
1949 i != end; ++i) { | 1943 i != end; ++i) { |
1950 DCHECK_EQ(parent_id, (*i)->ref(PARENT_ID)); | 1944 DCHECK_EQ(parent_id, (*i)->ref(PARENT_ID)); |
1951 result->push_back((*i)->ref(META_HANDLE)); | 1945 result->push_back((*i)->ref(META_HANDLE)); |
1952 } | 1946 } |
1953 } | 1947 } |
1954 | 1948 |
1955 } // namespace syncable | 1949 } // namespace syncable |
OLD | NEW |