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

Side by Side Diff: chrome/browser/sync/js_transaction_observer.cc

Issue 7190001: [Sync] Split DirectoryChangeListener for thread-safety (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix copyright Created 9 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/js_transaction_observer.h"
6
7 #include <sstream>
8 #include <string>
9
10 #include "base/logging.h"
11 #include "base/tracked.h"
12 #include "base/values.h"
13 #include "chrome/browser/sync/js_event_details.h"
14 #include "chrome/browser/sync/js_event_router.h"
15
16 namespace browser_sync {
17
18 JsTransactionObserver::JsTransactionObserver(
19 JsEventRouter* parent_router)
20 : parent_router_(parent_router) {
21 DCHECK(parent_router_);
22 }
23
24 JsTransactionObserver::~JsTransactionObserver() {
25 DCHECK(non_thread_safe_.CalledOnValidThread());
26 }
27
28 namespace {
29
30 std::string GetLocationString(const tracked_objects::Location& location) {
31 std::ostringstream oss;
32 oss << location.function_name() << "@"
33 << location.file_name() << ":" << location.line_number();
34 return oss.str();
35 }
36
37 } // namespace
38
39 void JsTransactionObserver::OnTransactionStart(
40 const tracked_objects::Location& location,
41 const syncable::WriterTag& writer) {
42 DCHECK(non_thread_safe_.CalledOnValidThread());
43 DictionaryValue details;
44 details.SetString("location", GetLocationString(location));
45 details.SetString("writer", syncable::WriterTagToString(writer));
46 parent_router_->RouteJsEvent("onTransactionStart",
47 JsEventDetails(&details));
48 }
49
50 void JsTransactionObserver::OnTransactionMutate(
51 const tracked_objects::Location& location,
52 const syncable::WriterTag& writer,
53 const syncable::OriginalEntries& originals,
54 const syncable::ModelTypeBitSet& models_with_changes) {
55 DCHECK(non_thread_safe_.CalledOnValidThread());
56 DictionaryValue details;
57 details.SetString("location", GetLocationString(location));
58 details.SetString("writer", syncable::WriterTagToString(writer));
59 details.Set("originals", syncable::OriginalEntriesToValue(originals));
60 details.Set("modelsWithChanges",
61 syncable::ModelTypeBitSetToValue(models_with_changes));
62 parent_router_->RouteJsEvent("onTransactionMutate",
63 JsEventDetails(&details));
64 }
65
66 void JsTransactionObserver::OnTransactionEnd(
67 const tracked_objects::Location& location,
68 const syncable::WriterTag& writer) {
69 DCHECK(non_thread_safe_.CalledOnValidThread());
70 DictionaryValue details;
71 details.SetString("location", GetLocationString(location));
72 details.SetString("writer", syncable::WriterTagToString(writer));
73 parent_router_->RouteJsEvent("onTransactionEnd",
74 JsEventDetails(&details));
75 }
76
77 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/js_transaction_observer.h ('k') | chrome/browser/sync/profile_sync_service_autofill_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698