diff options
author | earthdok@chromium.org <earthdok@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-25 19:12:17 +0000 |
---|---|---|
committer | earthdok@chromium.org <earthdok@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-25 19:12:17 +0000 |
commit | bfd80f0bbc586d6254724530c1dbe376fd18e7eb (patch) | |
tree | f2bbe743018b4bc5ffef0c67e7a45805ac520aa5 /sync/util | |
parent | aaffe1b11632e13935ef54148bfd6373e2c08cd7 (diff) | |
download | chromium_src-bfd80f0bbc586d6254724530c1dbe376fd18e7eb.zip chromium_src-bfd80f0bbc586d6254724530c1dbe376fd18e7eb.tar.gz chromium_src-bfd80f0bbc586d6254724530c1dbe376fd18e7eb.tar.bz2 |
Revert 213642 "Lock-free shutdown of profile sync service. Chang..."
Reverting due to memory leaks.
BUG=264325
> Lock-free shutdown of profile sync service. Changes include:
> * Disconnect non-frontend processor/associator to stop accessing directory
> so that sync backend can be shut down without waiting.
> * Change non-frontend controller so that creation/destruction of
> processor/associator doesn't depend on valid controller. So
> scoped wait on stopping controller can be removed.
> * Move sync thread to PSS. It's created when starting first backend and
> destroyed on last browser thread.
>
> BUG=19757
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=210333
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=210955
>
> Review URL: https://chromiumcodereview.appspot.com/16770005
TBR=haitaol@chromium.org
Review URL: https://codereview.chromium.org/20374005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213671 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/util')
-rw-r--r-- | sync/util/extensions_activity.cc | 39 | ||||
-rw-r--r-- | sync/util/extensions_activity.h | 64 | ||||
-rw-r--r-- | sync/util/extensions_activity_monitor.cc | 16 | ||||
-rw-r--r-- | sync/util/extensions_activity_monitor.h | 53 |
4 files changed, 69 insertions, 103 deletions
diff --git a/sync/util/extensions_activity.cc b/sync/util/extensions_activity.cc deleted file mode 100644 index dcccb26..0000000 --- a/sync/util/extensions_activity.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "sync/util/extensions_activity.h" - -namespace syncer { - -ExtensionsActivity::Record::Record() - : bookmark_write_count(0U) {} - -ExtensionsActivity::Record::~Record() {} - -ExtensionsActivity::ExtensionsActivity() {} - -ExtensionsActivity::~ExtensionsActivity() {} - -void ExtensionsActivity::GetAndClearRecords(Records* buffer) { - base::AutoLock lock(records_lock_); - buffer->clear(); - buffer->swap(records_); -} - -void ExtensionsActivity::PutRecords(const Records& records) { - base::AutoLock lock(records_lock_); - for (Records::const_iterator i = records.begin(); i != records.end(); ++i) { - records_[i->first].extension_id = i->second.extension_id; - records_[i->first].bookmark_write_count += i->second.bookmark_write_count; - } -} - -void ExtensionsActivity::UpdateRecord(const std::string& extension_id) { - base::AutoLock lock(records_lock_); - Record& record = records_[extension_id]; - record.extension_id = extension_id; - record.bookmark_write_count++; -} - -} // namespace syncer diff --git a/sync/util/extensions_activity.h b/sync/util/extensions_activity.h deleted file mode 100644 index 8178760..0000000 --- a/sync/util/extensions_activity.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef SYNC_UTIL_EXTENSIONS_ACTIVITY_H_ -#define SYNC_UTIL_EXTENSIONS_ACTIVITY_H_ - -#include <map> -#include <string> - -#include "base/basictypes.h" -#include "base/memory/ref_counted.h" -#include "base/synchronization/lock.h" -#include "sync/base/sync_export.h" - -namespace syncer { - -// A storage to record usage of extensions APIs to send to sync -// servers, with the ability to purge data once sync servers have -// acknowledged it (successful commit response). -class SYNC_EXPORT ExtensionsActivity - : public base::RefCountedThreadSafe<ExtensionsActivity> { - public: - // A data record of activity performed by extension |extension_id|. - struct SYNC_EXPORT Record { - Record(); - ~Record(); - - // The human-readable ID identifying the extension responsible - // for the activity reported in this Record. - std::string extension_id; - - // How many times the extension successfully invoked a write - // operation through the bookmarks API since the last CommitMessage. - uint32 bookmark_write_count; - }; - - typedef std::map<std::string, Record> Records; - - ExtensionsActivity(); - - // Fill |buffer| with all current records and then clear the - // internal records. Called on sync thread to append records to sync commit - // message. - void GetAndClearRecords(Records* buffer); - - // Merge |records| with the current set of records. Called on sync thread to - // put back records if sync commit failed. - void PutRecords(const Records& records); - - // Increment write count of the specified extension. - void UpdateRecord(const std::string& extension_id); - - private: - friend class base::RefCountedThreadSafe<ExtensionsActivity>; - ~ExtensionsActivity(); - - Records records_; - mutable base::Lock records_lock_; -}; - -} // namespace syncer - -#endif // SYNC_UTIL_EXTENSIONS_ACTIVITY_H_ diff --git a/sync/util/extensions_activity_monitor.cc b/sync/util/extensions_activity_monitor.cc new file mode 100644 index 0000000..fabe50b --- /dev/null +++ b/sync/util/extensions_activity_monitor.cc @@ -0,0 +1,16 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "sync/util/extensions_activity_monitor.h" + +namespace syncer { + +ExtensionsActivityMonitor::Record::Record() + : bookmark_write_count(0U) {} + +ExtensionsActivityMonitor::Record::~Record() {} + +ExtensionsActivityMonitor::~ExtensionsActivityMonitor() {} + +} // namespace syncer diff --git a/sync/util/extensions_activity_monitor.h b/sync/util/extensions_activity_monitor.h new file mode 100644 index 0000000..699f7b5 --- /dev/null +++ b/sync/util/extensions_activity_monitor.h @@ -0,0 +1,53 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef SYNC_UTIL_EXTENSIONS_ACTIVITY_MONITOR_H_ +#define SYNC_UTIL_EXTENSIONS_ACTIVITY_MONITOR_H_ + +#include <map> +#include <string> + +#include "base/basictypes.h" +#include "sync/base/sync_export.h" + +namespace syncer { + +// An interface to monitor usage of extensions APIs to send to sync +// servers, with the ability to purge data once sync servers have +// acknowledged it (successful commit response). +// +// All abstract methods are called from the sync thread. +class SYNC_EXPORT ExtensionsActivityMonitor { + public: + // A data record of activity performed by extension |extension_id|. + struct SYNC_EXPORT Record { + Record(); + ~Record(); + + // The human-readable ID identifying the extension responsible + // for the activity reported in this Record. + std::string extension_id; + + // How many times the extension successfully invoked a write + // operation through the bookmarks API since the last CommitMessage. + uint32 bookmark_write_count; + }; + + typedef std::map<std::string, Record> Records; + + // Fill |buffer| with all current records and then clear the + // internal records. + virtual void GetAndClearRecords(Records* buffer) = 0; + + // Merge |records| with the current set of records, adding the + // bookmark write counts for common Records. + virtual void PutRecords(const Records& records) = 0; + + protected: + virtual ~ExtensionsActivityMonitor(); +}; + +} // namespace syncer + +#endif // SYNC_UTIL_EXTENSIONS_ACTIVITY_MONITOR_H_ |