| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "sync/internal_api/js_mutation_event_observer.h" | 5 #include "sync/internal_api/js_mutation_event_observer.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include <string> | 10 #include <string> |
| 8 | 11 |
| 9 #include "base/location.h" | 12 #include "base/location.h" |
| 10 #include "base/logging.h" | 13 #include "base/logging.h" |
| 11 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/values.h" | 15 #include "base/values.h" |
| 13 #include "sync/js/js_event_details.h" | 16 #include "sync/js/js_event_details.h" |
| 14 #include "sync/js/js_event_handler.h" | 17 #include "sync/js/js_event_handler.h" |
| 15 | 18 |
| 16 namespace syncer { | 19 namespace syncer { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 38 namespace { | 41 namespace { |
| 39 | 42 |
| 40 // Max number of changes we attempt to convert to values (to avoid | 43 // Max number of changes we attempt to convert to values (to avoid |
| 41 // running out of memory). | 44 // running out of memory). |
| 42 const size_t kChangeLimit = 100; | 45 const size_t kChangeLimit = 100; |
| 43 | 46 |
| 44 } // namespace | 47 } // namespace |
| 45 | 48 |
| 46 void JsMutationEventObserver::OnChangesApplied( | 49 void JsMutationEventObserver::OnChangesApplied( |
| 47 ModelType model_type, | 50 ModelType model_type, |
| 48 int64 write_transaction_id, | 51 int64_t write_transaction_id, |
| 49 const ImmutableChangeRecordList& changes) { | 52 const ImmutableChangeRecordList& changes) { |
| 50 if (!event_handler_.IsInitialized()) { | 53 if (!event_handler_.IsInitialized()) { |
| 51 return; | 54 return; |
| 52 } | 55 } |
| 53 base::DictionaryValue details; | 56 base::DictionaryValue details; |
| 54 details.SetString("modelType", ModelTypeToString(model_type)); | 57 details.SetString("modelType", ModelTypeToString(model_type)); |
| 55 details.SetString("writeTransactionId", | 58 details.SetString("writeTransactionId", |
| 56 base::Int64ToString(write_transaction_id)); | 59 base::Int64ToString(write_transaction_id)); |
| 57 base::Value* changes_value = NULL; | 60 base::Value* changes_value = NULL; |
| 58 const size_t changes_size = changes.Get().size(); | 61 const size_t changes_size = changes.Get().size(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 const std::string& name, const JsEventDetails& details) { | 104 const std::string& name, const JsEventDetails& details) { |
| 102 if (!event_handler_.IsInitialized()) { | 105 if (!event_handler_.IsInitialized()) { |
| 103 NOTREACHED(); | 106 NOTREACHED(); |
| 104 return; | 107 return; |
| 105 } | 108 } |
| 106 event_handler_.Call(from_here, | 109 event_handler_.Call(from_here, |
| 107 &JsEventHandler::HandleJsEvent, name, details); | 110 &JsEventHandler::HandleJsEvent, name, details); |
| 108 } | 111 } |
| 109 | 112 |
| 110 } // namespace syncer | 113 } // namespace syncer |
| OLD | NEW |