summaryrefslogtreecommitdiffstats
path: root/net/socket_stream/socket_stream_job_manager.h
blob: c9050f674059095ae9bb5937e8fd79c6ce855632 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2010 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.

#ifndef NET_SOCKET_STREAM_SOCKET_STREAM_JOB_MANAGER_H_
#define NET_SOCKET_STREAM_SOCKET_STREAM_JOB_MANAGER_H_
#pragma once

#include <map>
#include <string>

#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:
  // Returns the singleton instance.
  static SocketStreamJobManager* GetInstance();

  SocketStreamJob* CreateJob(
      const GURL& url, SocketStream::Delegate* delegate) const;

  SocketStreamJob::ProtocolFactory* RegisterProtocolFactory(
      const std::string& scheme, SocketStreamJob::ProtocolFactory* factory);

 private:
  friend struct DefaultSingletonTraits<SocketStreamJobManager>;
  typedef std::map<std::string, SocketStreamJob::ProtocolFactory*> FactoryMap;

  SocketStreamJobManager();
  ~SocketStreamJobManager();

  mutable base::Lock lock_;
  FactoryMap factories_;

  DISALLOW_COPY_AND_ASSIGN(SocketStreamJobManager);
};

}  // namespace net

#endif  // NET_SOCKET_STREAM_SOCKET_STREAM_JOB_MANAGER_H_