Home | History | Annotate | Download | only in socket_stream
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef NET_SOCKET_STREAM_SOCKET_STREAM_JOB_MANAGER_H_
      6 #define NET_SOCKET_STREAM_SOCKET_STREAM_JOB_MANAGER_H_
      7 #pragma once
      8 
      9 #include <map>
     10 #include <string>
     11 
     12 #include "net/socket_stream/socket_stream.h"
     13 #include "net/socket_stream/socket_stream_job.h"
     14 
     15 template <typename T> struct DefaultSingletonTraits;
     16 class GURL;
     17 
     18 namespace net {
     19 
     20 class SocketStreamJobManager {
     21  public:
     22   // Returns the singleton instance.
     23   static SocketStreamJobManager* GetInstance();
     24 
     25   SocketStreamJob* CreateJob(
     26       const GURL& url, SocketStream::Delegate* delegate) const;
     27 
     28   SocketStreamJob::ProtocolFactory* RegisterProtocolFactory(
     29       const std::string& scheme, SocketStreamJob::ProtocolFactory* factory);
     30 
     31  private:
     32   friend struct DefaultSingletonTraits<SocketStreamJobManager>;
     33   typedef std::map<std::string, SocketStreamJob::ProtocolFactory*> FactoryMap;
     34 
     35   SocketStreamJobManager();
     36   ~SocketStreamJobManager();
     37 
     38   mutable base::Lock lock_;
     39   FactoryMap factories_;
     40 
     41   DISALLOW_COPY_AND_ASSIGN(SocketStreamJobManager);
     42 };
     43 
     44 }  // namespace net
     45 
     46 #endif  // NET_SOCKET_STREAM_SOCKET_STREAM_JOB_MANAGER_H_
     47