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

Side by Side Diff: sync/internal_api/js_mutation_event_observer.cc

Issue 10698014: [Sync] Rename csync namespace to syncer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 5 months 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) 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 <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"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "sync/js/js_event_details.h" 13 #include "sync/js/js_event_details.h"
14 #include "sync/js/js_event_handler.h" 14 #include "sync/js/js_event_handler.h"
15 15
16 namespace csync { 16 namespace syncer {
17 17
18 JsMutationEventObserver::JsMutationEventObserver() 18 JsMutationEventObserver::JsMutationEventObserver()
19 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {} 19 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {}
20 20
21 JsMutationEventObserver::~JsMutationEventObserver() { 21 JsMutationEventObserver::~JsMutationEventObserver() {
22 DCHECK(CalledOnValidThread()); 22 DCHECK(CalledOnValidThread());
23 } 23 }
24 24
25 base::WeakPtr<JsMutationEventObserver> JsMutationEventObserver::AsWeakPtr() { 25 base::WeakPtr<JsMutationEventObserver> JsMutationEventObserver::AsWeakPtr() {
26 return weak_ptr_factory_.GetWeakPtr(); 26 return weak_ptr_factory_.GetWeakPtr();
(...skipping 12 matching lines...) Expand all
39 39
40 // 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
41 // running out of memory). 41 // running out of memory).
42 const size_t kChangeLimit = 100; 42 const size_t kChangeLimit = 100;
43 43
44 } // namespace 44 } // namespace
45 45
46 void JsMutationEventObserver::OnChangesApplied( 46 void JsMutationEventObserver::OnChangesApplied(
47 syncable::ModelType model_type, 47 syncable::ModelType model_type,
48 int64 write_transaction_id, 48 int64 write_transaction_id,
49 const csync::ImmutableChangeRecordList& changes) { 49 const syncer::ImmutableChangeRecordList& changes) {
50 if (!event_handler_.IsInitialized()) { 50 if (!event_handler_.IsInitialized()) {
51 return; 51 return;
52 } 52 }
53 DictionaryValue details; 53 DictionaryValue details;
54 details.SetString("modelType", syncable::ModelTypeToString(model_type)); 54 details.SetString("modelType", syncable::ModelTypeToString(model_type));
55 details.SetString("writeTransactionId", 55 details.SetString("writeTransactionId",
56 base::Int64ToString(write_transaction_id)); 56 base::Int64ToString(write_transaction_id));
57 base::Value* changes_value = NULL; 57 base::Value* changes_value = NULL;
58 const size_t changes_size = changes.Get().size(); 58 const size_t changes_size = changes.Get().size();
59 if (changes_size <= kChangeLimit) { 59 if (changes_size <= kChangeLimit) {
60 ListValue* changes_list = new ListValue(); 60 ListValue* changes_list = new ListValue();
61 for (csync::ChangeRecordList::const_iterator it = 61 for (syncer::ChangeRecordList::const_iterator it =
62 changes.Get().begin(); it != changes.Get().end(); ++it) { 62 changes.Get().begin(); it != changes.Get().end(); ++it) {
63 changes_list->Append(it->ToValue()); 63 changes_list->Append(it->ToValue());
64 } 64 }
65 changes_value = changes_list; 65 changes_value = changes_list;
66 } else { 66 } else {
67 changes_value = 67 changes_value =
68 Value::CreateStringValue( 68 Value::CreateStringValue(
69 base::Uint64ToString(static_cast<uint64>(changes_size)) + 69 base::Uint64ToString(static_cast<uint64>(changes_size)) +
70 " changes"); 70 " changes");
71 } 71 }
(...skipping 30 matching lines...) Expand all
102 const tracked_objects::Location& from_here, 102 const tracked_objects::Location& from_here,
103 const std::string& name, const JsEventDetails& details) { 103 const std::string& name, const JsEventDetails& details) {
104 if (!event_handler_.IsInitialized()) { 104 if (!event_handler_.IsInitialized()) {
105 NOTREACHED(); 105 NOTREACHED();
106 return; 106 return;
107 } 107 }
108 event_handler_.Call(from_here, 108 event_handler_.Call(from_here,
109 &JsEventHandler::HandleJsEvent, name, details); 109 &JsEventHandler::HandleJsEvent, name, details);
110 } 110 }
111 111
112 } // namespace csync 112 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/js_mutation_event_observer.h ('k') | sync/internal_api/js_mutation_event_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698