summaryrefslogtreecommitdiffstats
path: root/net/socket_stream
diff options
context:
space:
mode:
Diffstat (limited to 'net/socket_stream')
-rw-r--r--net/socket_stream/socket_stream_job.cc9
-rw-r--r--net/socket_stream/socket_stream_job_manager.cc7
-rw-r--r--net/socket_stream/socket_stream_job_manager.h9
3 files changed, 17 insertions, 8 deletions
diff --git a/net/socket_stream/socket_stream_job.cc b/net/socket_stream/socket_stream_job.cc
index 8d1da73..6636233 100644
--- a/net/socket_stream/socket_stream_job.cc
+++ b/net/socket_stream/socket_stream_job.cc
@@ -9,20 +9,17 @@
namespace net {
-static SocketStreamJobManager* GetJobManager() {
- return Singleton<SocketStreamJobManager>::get();
-}
-
// static
SocketStreamJob::ProtocolFactory* SocketStreamJob::RegisterProtocolFactory(
const std::string& scheme, ProtocolFactory* factory) {
- return GetJobManager()->RegisterProtocolFactory(scheme, factory);
+ return SocketStreamJobManager::GetInstance()->RegisterProtocolFactory(
+ scheme, factory);
}
// static
SocketStreamJob* SocketStreamJob::CreateSocketStreamJob(
const GURL& url, SocketStream::Delegate* delegate) {
- return GetJobManager()->CreateJob(url, delegate);
+ return SocketStreamJobManager::GetInstance()->CreateJob(url, delegate);
}
SocketStreamJob::SocketStreamJob() {}
diff --git a/net/socket_stream/socket_stream_job_manager.cc b/net/socket_stream/socket_stream_job_manager.cc
index 7dd0d6b..de2f0a8 100644
--- a/net/socket_stream/socket_stream_job_manager.cc
+++ b/net/socket_stream/socket_stream_job_manager.cc
@@ -4,6 +4,8 @@
#include "net/socket_stream/socket_stream_job_manager.h"
+#include "base/singleton.h"
+
namespace net {
SocketStreamJobManager::SocketStreamJobManager() {
@@ -12,6 +14,11 @@ SocketStreamJobManager::SocketStreamJobManager() {
SocketStreamJobManager::~SocketStreamJobManager() {
}
+// static
+SocketStreamJobManager* SocketStreamJobManager::GetInstance() {
+ return Singleton<SocketStreamJobManager>::get();
+}
+
SocketStreamJob* SocketStreamJobManager::CreateJob(
const GURL& url, SocketStream::Delegate* delegate) const {
// If url is invalid, create plain SocketStreamJob, which will close
diff --git a/net/socket_stream/socket_stream_job_manager.h b/net/socket_stream/socket_stream_job_manager.h
index 1150058..fbd572d 100644
--- a/net/socket_stream/socket_stream_job_manager.h
+++ b/net/socket_stream/socket_stream_job_manager.h
@@ -12,14 +12,15 @@
#include "net/socket_stream/socket_stream.h"
#include "net/socket_stream/socket_stream_job.h"
+template <typename T> struct DefaultSingletonTraits;
class GURL;
namespace net {
class SocketStreamJobManager {
public:
- SocketStreamJobManager();
- ~SocketStreamJobManager();
+ // Returns the singleton instance.
+ static SocketStreamJobManager* GetInstance();
SocketStreamJob* CreateJob(
const GURL& url, SocketStream::Delegate* delegate) const;
@@ -28,8 +29,12 @@ class SocketStreamJobManager {
const std::string& scheme, SocketStreamJob::ProtocolFactory* factory);
private:
+ friend struct DefaultSingletonTraits<SocketStreamJobManager>;
typedef std::map<std::string, SocketStreamJob::ProtocolFactory*> FactoryMap;
+ SocketStreamJobManager();
+ ~SocketStreamJobManager();
+
mutable Lock lock_;
FactoryMap factories_;