diff options
author | Ben Murdoch <benm@google.com> | 2010-07-29 17:14:53 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-08-04 14:29:45 +0100 |
commit | c407dc5cd9bdc5668497f21b26b09d988ab439de (patch) | |
tree | 7eaf8707c0309516bdb042ad976feedaf72b0bb1 /chrome/browser/automation/automation_provider_list.cc | |
parent | 0998b1cdac5733f299c12d88bc31ef9c8035b8fa (diff) | |
download | external_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.zip external_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.tar.gz external_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.tar.bz2 |
Merge Chromium src@r53293
Change-Id: Ia79acf8670f385cee48c45b0a75371d8e950af34
Diffstat (limited to 'chrome/browser/automation/automation_provider_list.cc')
-rw-r--r-- | chrome/browser/automation/automation_provider_list.cc | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/chrome/browser/automation/automation_provider_list.cc b/chrome/browser/automation/automation_provider_list.cc new file mode 100644 index 0000000..6676626 --- /dev/null +++ b/chrome/browser/automation/automation_provider_list.cc @@ -0,0 +1,52 @@ +// Copyright (c) 2006-2008 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 "chrome/browser/automation/automation_provider_list.h" + +#include <algorithm> + +#include "base/logging.h" +#include "chrome/browser/automation/automation_provider.h" +#include "chrome/browser/browser_process.h" + +AutomationProviderList* AutomationProviderList::instance_ = NULL; + +AutomationProviderList::AutomationProviderList() { +} + +AutomationProviderList::~AutomationProviderList() { + iterator iter = automation_providers_.begin(); + while (iter != automation_providers_.end()) { + (*iter)->Release(); + iter = automation_providers_.erase(iter); + } + instance_ = NULL; +} + +bool AutomationProviderList::AddProvider(AutomationProvider* provider) { + provider->AddRef(); + automation_providers_.push_back(provider); + return true; +} + +bool AutomationProviderList::RemoveProvider(AutomationProvider* provider) { + const iterator remove_provider = + find(automation_providers_.begin(), automation_providers_.end(), provider); + if (remove_provider != automation_providers_.end()) { + (*remove_provider)->Release(); + automation_providers_.erase(remove_provider); + if (automation_providers_.empty()) + OnLastProviderRemoved(); + return true; + } + return false; +} + +AutomationProviderList* AutomationProviderList::GetInstance() { + if (!instance_) { + instance_ = new AutomationProviderList; + } + DCHECK(NULL != instance_); + return instance_; +} |