summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-09 23:18:10 +0000
committerzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-09 23:18:10 +0000
commita928f731a13ddd42b993a3b6711fbf0985c89df6 (patch)
treecbc582fd518d7566ebffff7e7804d793020649d4
parented732209f6a47ea91abebb574c39ba10b960b67a (diff)
downloadchromium_src-a928f731a13ddd42b993a3b6711fbf0985c89df6.zip
chromium_src-a928f731a13ddd42b993a3b6711fbf0985c89df6.tar.gz
chromium_src-a928f731a13ddd42b993a3b6711fbf0985c89df6.tar.bz2
Merge 100515 - [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 TBR=zea@chromium.org Review URL: http://codereview.chromium.org/7863016 git-svn-id: svn://svn.chromium.org/chrome/branches/874/src@100532 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;
}