diff options
author | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-08 10:43:08 +0000 |
---|---|---|
committer | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-08 10:43:08 +0000 |
commit | 687b96058845cdaa59f9d81c468f81222e60bdfd (patch) | |
tree | 9c97670a35e5f6abe40f3c4bf50ee7b5a257a0e3 /chrome/test | |
parent | d22618c155cd40c5740755a5f0bcaab59f13f9a7 (diff) | |
download | chromium_src-687b96058845cdaa59f9d81c468f81222e60bdfd.zip chromium_src-687b96058845cdaa59f9d81c468f81222e60bdfd.tar.gz chromium_src-687b96058845cdaa59f9d81c468f81222e60bdfd.tar.bz2 |
Add a new GetInstance() method for singleton classes, take 2.
This is a small step towards making all singleton classes use the Singleton<T> pattern within their code and not expect the callers to know about it.
This CL includes all files except those under chrome/browser, chrome/net, chrome/service and third_party/WebKit (these will be done in future CLs).
Suggested files to focus for reviewers:
- joi@ for files under src/ceee
- tommi@ for files under src/chrome_frame
- maruel@ for the rest of the files.
BUG=65298
TEST=all existing tests should continue to pass.
Review URL: http://codereview.chromium.org/5581008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68577 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/webdriver/commands/create_session.cc | 2 | ||||
-rw-r--r-- | chrome/test/webdriver/commands/session_with_id.cc | 2 | ||||
-rw-r--r-- | chrome/test/webdriver/commands/webdriver_command.cc | 2 | ||||
-rw-r--r-- | chrome/test/webdriver/server.cc | 3 | ||||
-rw-r--r-- | chrome/test/webdriver/session_manager.cc | 5 | ||||
-rw-r--r-- | chrome/test/webdriver/session_manager.h | 3 |
6 files changed, 12 insertions, 5 deletions
diff --git a/chrome/test/webdriver/commands/create_session.cc b/chrome/test/webdriver/commands/create_session.cc index 30c71c7..7ba85a4 100644 --- a/chrome/test/webdriver/commands/create_session.cc +++ b/chrome/test/webdriver/commands/create_session.cc @@ -15,7 +15,7 @@ namespace webdriver { void CreateSession::ExecutePost(Response* const response) { - SessionManager* session_manager = Singleton<SessionManager>::get(); + SessionManager* session_manager = SessionManager::GetInstance(); std::string session_id; if (!session_manager->Create(&session_id)) { diff --git a/chrome/test/webdriver/commands/session_with_id.cc b/chrome/test/webdriver/commands/session_with_id.cc index e2dcced..682f5a2 100644 --- a/chrome/test/webdriver/commands/session_with_id.cc +++ b/chrome/test/webdriver/commands/session_with_id.cc @@ -41,7 +41,7 @@ void SessionWithID::ExecuteGet(Response* const response) { } void SessionWithID::ExecuteDelete(Response* const response) { - Singleton<SessionManager>::get()->Delete(session_->id()); + SessionManager::GetInstance()->Delete(session_->id()); response->set_status(kSuccess); } diff --git a/chrome/test/webdriver/commands/webdriver_command.cc b/chrome/test/webdriver/commands/webdriver_command.cc index da1b601..206679e 100644 --- a/chrome/test/webdriver/commands/webdriver_command.cc +++ b/chrome/test/webdriver/commands/webdriver_command.cc @@ -51,7 +51,7 @@ bool WebDriverCommand::Init(Response* const response) { } VLOG(1) << "Fetching session: " << session_id; - session_ = Singleton<SessionManager>::get()->GetSession(session_id); + session_ = SessionManager::GetInstance()->GetSession(session_id); if (session_ == NULL) { response->set_value(Value::CreateStringValue( "Session not found: " + session_id)); diff --git a/chrome/test/webdriver/server.cc b/chrome/test/webdriver/server.cc index ad496b1..8465f14 100644 --- a/chrome/test/webdriver/server.cc +++ b/chrome/test/webdriver/server.cc @@ -106,8 +106,7 @@ int main(int argc, char *argv[]) { } VLOG(1) << "Using port: " << port; - webdriver::SessionManager* session = - Singleton<webdriver::SessionManager>::get(); + webdriver::SessionManager* session = webdriver::SessionManager::GetInstance(); session->SetIPAddress(port); // Initialize SHTTPD context. diff --git a/chrome/test/webdriver/session_manager.cc b/chrome/test/webdriver/session_manager.cc index 6e49bb6..ab7db24 100644 --- a/chrome/test/webdriver/session_manager.cc +++ b/chrome/test/webdriver/session_manager.cc @@ -183,4 +183,9 @@ Session* SessionManager::GetSession(const std::string& id) const { return it->second; } +// static +SessionManager* SessionManager::GetInstance() { + return Singleton<SessionManager>::get(); +} + } // namespace webdriver diff --git a/chrome/test/webdriver/session_manager.h b/chrome/test/webdriver/session_manager.h index e93843f..91db207 100644 --- a/chrome/test/webdriver/session_manager.h +++ b/chrome/test/webdriver/session_manager.h @@ -21,6 +21,9 @@ namespace webdriver { // their own profiles. class SessionManager { public: + // Returns the singleton instance. + static SessionManager* GetInstance(); + std::string GetIPAddress(); bool SetIPAddress(const std::string& port); |