summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-09 22:18:15 +0000
committerzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-09 22:18:15 +0000
commit8ebabc4e5f83fe66ff719f732b99971eef067e99 (patch)
tree3094b698dfe8a700db0e2ae1ce668c05f687bb65
parent9ad0dfea07bc87aeb062ad07705882e86d7523a3 (diff)
downloadchromium_src-8ebabc4e5f83fe66ff719f732b99971eef067e99.zip
chromium_src-8ebabc4e5f83fe66ff719f732b99971eef067e99.tar.gz
chromium_src-8ebabc4e5f83fe66ff719f732b99971eef067e99.tar.bz2
[Sync] Don't notify the transaction observer of huge mutation sets.
The transaction observer is currently only used for debug information sent to chrome://sync_internals. When we have large numbers of changes within a single transaction, our mutation set can grow exceedingly large, and the unnecessary copying we perform in sending the data to the transaction observer can result in out of memory crashes. This change limits the size of the mutation sets we copy to 1000 elements. If the size is larger, we send a dummy empty mutation set instead. BUG=90169 TEST=turn on encryption on an account with >1000 items. Ensure none are printed in the events pane of about:sync Review URL: http://codereview.chromium.org/7861005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100515 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/syncable/syncable.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/chrome/browser/sync/syncable/syncable.cc b/chrome/browser/sync/syncable/syncable.cc
index 4ece5bd..288c3dd 100644
--- a/chrome/browser/sync/syncable/syncable.cc
+++ b/chrome/browser/sync/syncable/syncable.cc
@@ -64,6 +64,9 @@ static const InvariantCheckLevel kInvariantCheckLevel = VERIFY_IN_MEMORY;
// Max number of milliseconds to spend checking syncable entry invariants
static const int kInvariantCheckMaxMs = 50;
+
+// Max number of mutations in a mutation set we permit passing to observers.
+static const size_t kMutationObserverLimit = 1000;
} // namespace
using std::string;
@@ -1257,9 +1260,21 @@ ModelTypeBitSet WriteTransaction::NotifyTransactionChangingAndEnding(
ModelTypeBitSet models_with_changes =
delegate->HandleTransactionEndingChangeEvent(this);
- dirkernel_->observers->Notify(
- &TransactionObserver::OnTransactionMutate,
- from_here_, writer_, mutations, models_with_changes);
+ // These notifications pass the mutation list around by value, which when we
+ // rewrite all sync data can be extremely large and result in out of memory
+ // errors (see crbug.com/90169). As a result, when there are more than
+ // kMutationObserverLimit mutations, we pass around an empty mutation set.
+ if (mutations.size() < kMutationObserverLimit) {
+ dirkernel_->observers->Notify(
+ &TransactionObserver::OnTransactionMutate,
+ from_here_, writer_, mutations, models_with_changes);
+ } else {
+ EntryKernelMutationSet dummy_mutations; // Empty set.
+ dirkernel_->observers->Notify(
+ &TransactionObserver::OnTransactionMutate,
+ from_here_, writer_, dummy_mutations, models_with_changes);
+ }
+
return models_with_changes;
}