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

Side by Side Diff: chrome/browser/sync/js/js_mutation_event_observer.cc

Issue 8741001: Remove sync OnTransaction{Start,End} notification (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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/js/js_mutation_event_observer.h" 5 #include "chrome/browser/sync/js/js_mutation_event_observer.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 17 matching lines...) Expand all
28 28
29 void JsMutationEventObserver::InvalidateWeakPtrs() { 29 void JsMutationEventObserver::InvalidateWeakPtrs() {
30 weak_ptr_factory_.InvalidateWeakPtrs(); 30 weak_ptr_factory_.InvalidateWeakPtrs();
31 } 31 }
32 32
33 void JsMutationEventObserver::SetJsEventHandler( 33 void JsMutationEventObserver::SetJsEventHandler(
34 const WeakHandle<JsEventHandler>& event_handler) { 34 const WeakHandle<JsEventHandler>& event_handler) {
35 event_handler_ = event_handler; 35 event_handler_ = event_handler;
36 } 36 }
37 37
38 void JsMutationEventObserver::OnTransactionStart(
39 const tracked_objects::Location& location,
40 const syncable::WriterTag& writer) {
41 DCHECK(non_thread_safe_.CalledOnValidThread());
42 if (!event_handler_.IsInitialized()) {
43 return;
44 }
45 DictionaryValue details;
46 details.SetString("location", location.ToString());
47 details.SetString("writer", syncable::WriterTagToString(writer));
48 HandleJsEvent(FROM_HERE, "onTransactionStart", JsEventDetails(&details));
49 }
50
51 namespace { 38 namespace {
52 39
53 // Max number of changes we attempt to convert to values (to avoid 40 // Max number of changes we attempt to convert to values (to avoid
54 // running out of memory). 41 // running out of memory).
55 const size_t kChangeLimit = 100; 42 const size_t kChangeLimit = 100;
56 43
57 } // namespace 44 } // namespace
58 45
59 void JsMutationEventObserver::OnChangesApplied( 46 void JsMutationEventObserver::OnChangesApplied(
60 syncable::ModelType model_type, 47 syncable::ModelType model_type,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 return; 91 return;
105 } 92 }
106 DictionaryValue details; 93 DictionaryValue details;
107 details.Set("writeTransactionInfo", 94 details.Set("writeTransactionInfo",
108 write_transaction_info.Get().ToValue(kChangeLimit)); 95 write_transaction_info.Get().ToValue(kChangeLimit));
109 details.Set("modelsWithChanges", 96 details.Set("modelsWithChanges",
110 syncable::ModelTypeBitSetToValue(models_with_changes)); 97 syncable::ModelTypeBitSetToValue(models_with_changes));
111 HandleJsEvent(FROM_HERE, "onTransactionWrite", JsEventDetails(&details)); 98 HandleJsEvent(FROM_HERE, "onTransactionWrite", JsEventDetails(&details));
112 } 99 }
113 100
114 void JsMutationEventObserver::OnTransactionEnd(
115 const tracked_objects::Location& location,
116 const syncable::WriterTag& writer) {
117 DCHECK(non_thread_safe_.CalledOnValidThread());
118 if (!event_handler_.IsInitialized()) {
119 return;
120 }
121 DictionaryValue details;
122 details.SetString("location", location.ToString());
123 details.SetString("writer", syncable::WriterTagToString(writer));
124 HandleJsEvent(FROM_HERE, "onTransactionEnd", JsEventDetails(&details));
125 }
126
127 void JsMutationEventObserver::HandleJsEvent( 101 void JsMutationEventObserver::HandleJsEvent(
128 const tracked_objects::Location& from_here, 102 const tracked_objects::Location& from_here,
129 const std::string& name, const JsEventDetails& details) { 103 const std::string& name, const JsEventDetails& details) {
130 if (!event_handler_.IsInitialized()) { 104 if (!event_handler_.IsInitialized()) {
131 NOTREACHED(); 105 NOTREACHED();
132 return; 106 return;
133 } 107 }
134 event_handler_.Call(from_here, 108 event_handler_.Call(from_here,
135 &JsEventHandler::HandleJsEvent, name, details); 109 &JsEventHandler::HandleJsEvent, name, details);
136 } 110 }
137 111
138 } // namespace browser_sync 112 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/js/js_mutation_event_observer.h ('k') | chrome/browser/sync/syncable/syncable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698