Home | History | Annotate | Download | only in util
      1 // Copyright 2013 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 "sync/util/extensions_activity.h"
      6 
      7 namespace syncer {
      8 
      9 ExtensionsActivity::Record::Record()
     10     : bookmark_write_count(0U) {}
     11 
     12 ExtensionsActivity::Record::~Record() {}
     13 
     14 ExtensionsActivity::ExtensionsActivity() {}
     15 
     16 ExtensionsActivity::~ExtensionsActivity() {}
     17 
     18 void ExtensionsActivity::GetAndClearRecords(Records* buffer) {
     19   base::AutoLock lock(records_lock_);
     20   buffer->clear();
     21   buffer->swap(records_);
     22 }
     23 
     24 void ExtensionsActivity::PutRecords(const Records& records) {
     25   base::AutoLock lock(records_lock_);
     26   for (Records::const_iterator i = records.begin(); i != records.end(); ++i) {
     27     records_[i->first].extension_id = i->second.extension_id;
     28     records_[i->first].bookmark_write_count += i->second.bookmark_write_count;
     29   }
     30 }
     31 
     32 void ExtensionsActivity::UpdateRecord(const std::string& extension_id) {
     33   base::AutoLock lock(records_lock_);
     34   Record& record = records_[extension_id];
     35   record.extension_id = extension_id;
     36   record.bookmark_write_count++;
     37 }
     38 
     39 }  // namespace syncer
     40