| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/util/extensions_activity_monitor.h" | 5 #include "chrome/browser/sync/util/extensions_activity_monitor.h" |
| 6 | 6 |
| 7 #include "base/task.h" | 7 #include "base/task.h" |
| 8 #include "chrome/browser/browser_thread.h" | 8 #include "chrome/browser/browser_thread.h" |
| 9 #include "chrome/browser/extensions/extension_bookmarks_module.h" | 9 #include "chrome/browser/extensions/extension_bookmarks_module.h" |
| 10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 59 | 59 |
| 60 // The registrar calls RemoveAll in its dtor (which would happen in a | 60 // The registrar calls RemoveAll in its dtor (which would happen in a |
| 61 // moment but explicitly call this so it is clear why we need to be on the | 61 // moment but explicitly call this so it is clear why we need to be on the |
| 62 // ui_loop_. | 62 // ui_loop_. |
| 63 registrar_.RemoveAll(); | 63 registrar_.RemoveAll(); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 void ExtensionsActivityMonitor::GetAndClearRecords(Records* buffer) { | 67 void ExtensionsActivityMonitor::GetAndClearRecords(Records* buffer) { |
| 68 AutoLock lock(records_lock_); | 68 base::AutoLock lock(records_lock_); |
| 69 buffer->clear(); | 69 buffer->clear(); |
| 70 buffer->swap(records_); | 70 buffer->swap(records_); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void ExtensionsActivityMonitor::PutRecords(const Records& records) { | 73 void ExtensionsActivityMonitor::PutRecords(const Records& records) { |
| 74 AutoLock lock(records_lock_); | 74 base::AutoLock lock(records_lock_); |
| 75 for (Records::const_iterator i = records.begin(); i != records.end(); ++i) { | 75 for (Records::const_iterator i = records.begin(); i != records.end(); ++i) { |
| 76 records_[i->first].extension_id = i->second.extension_id; | 76 records_[i->first].extension_id = i->second.extension_id; |
| 77 records_[i->first].bookmark_write_count += i->second.bookmark_write_count; | 77 records_[i->first].bookmark_write_count += i->second.bookmark_write_count; |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 void ExtensionsActivityMonitor::Observe(NotificationType type, | 81 void ExtensionsActivityMonitor::Observe(NotificationType type, |
| 82 const NotificationSource& source, | 82 const NotificationSource& source, |
| 83 const NotificationDetails& details) { | 83 const NotificationDetails& details) { |
| 84 AutoLock lock(records_lock_); | 84 base::AutoLock lock(records_lock_); |
| 85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 86 const Extension* extension = Source<const Extension>(source).ptr(); | 86 const Extension* extension = Source<const Extension>(source).ptr(); |
| 87 const BookmarksFunction* f = Details<const BookmarksFunction>(details).ptr(); | 87 const BookmarksFunction* f = Details<const BookmarksFunction>(details).ptr(); |
| 88 if (f->name() == "bookmarks.update" || | 88 if (f->name() == "bookmarks.update" || |
| 89 f->name() == "bookmarks.move" || | 89 f->name() == "bookmarks.move" || |
| 90 f->name() == "bookmarks.create" || | 90 f->name() == "bookmarks.create" || |
| 91 f->name() == "bookmarks.removeTree" || | 91 f->name() == "bookmarks.removeTree" || |
| 92 f->name() == "bookmarks.remove") { | 92 f->name() == "bookmarks.remove") { |
| 93 Record& record = records_[extension->id()]; | 93 Record& record = records_[extension->id()]; |
| 94 record.extension_id = extension->id(); | 94 record.extension_id = extension->id(); |
| 95 record.bookmark_write_count++; | 95 record.bookmark_write_count++; |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace browser_sync | 99 } // namespace browser_sync |
| OLD | NEW |