OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/socket_stream/socket_stream_job_manager.h" | 5 #include "net/socket_stream/socket_stream_job_manager.h" |
6 | 6 |
| 7 #include "base/singleton.h" |
| 8 |
7 namespace net { | 9 namespace net { |
8 | 10 |
9 SocketStreamJobManager::SocketStreamJobManager() { | 11 SocketStreamJobManager::SocketStreamJobManager() { |
10 } | 12 } |
11 | 13 |
12 SocketStreamJobManager::~SocketStreamJobManager() { | 14 SocketStreamJobManager::~SocketStreamJobManager() { |
13 } | 15 } |
14 | 16 |
| 17 // static |
| 18 SocketStreamJobManager* SocketStreamJobManager::GetInstance() { |
| 19 return Singleton<SocketStreamJobManager>::get(); |
| 20 } |
| 21 |
15 SocketStreamJob* SocketStreamJobManager::CreateJob( | 22 SocketStreamJob* SocketStreamJobManager::CreateJob( |
16 const GURL& url, SocketStream::Delegate* delegate) const { | 23 const GURL& url, SocketStream::Delegate* delegate) const { |
17 // If url is invalid, create plain SocketStreamJob, which will close | 24 // If url is invalid, create plain SocketStreamJob, which will close |
18 // the socket immediately. | 25 // the socket immediately. |
19 if (!url.is_valid()) { | 26 if (!url.is_valid()) { |
20 SocketStreamJob* job = new SocketStreamJob(); | 27 SocketStreamJob* job = new SocketStreamJob(); |
21 job->InitSocketStream(new SocketStream(url, delegate)); | 28 job->InitSocketStream(new SocketStream(url, delegate)); |
22 return job; | 29 return job; |
23 } | 30 } |
24 | 31 |
(...skipping 25 matching lines...) Expand all Loading... |
50 } | 57 } |
51 if (factory) { | 58 if (factory) { |
52 factories_[scheme] = factory; | 59 factories_[scheme] = factory; |
53 } else if (found != factories_.end()) { | 60 } else if (found != factories_.end()) { |
54 factories_.erase(found); | 61 factories_.erase(found); |
55 } | 62 } |
56 return old_factory; | 63 return old_factory; |
57 } | 64 } |
58 | 65 |
59 } // namespace net | 66 } // namespace net |
OLD | NEW |