OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef COMPONENTS_DEVTOOLS_DISCOVERY_DEVTOOLS_DISCOVERY_MANAGER_H_ | 5 #ifndef COMPONENTS_DEVTOOLS_DISCOVERY_DEVTOOLS_DISCOVERY_MANAGER_H_ |
6 #define COMPONENTS_DEVTOOLS_DISCOVERY_DEVTOOLS_DISCOVERY_MANAGER_H_ | 6 #define COMPONENTS_DEVTOOLS_DISCOVERY_DEVTOOLS_DISCOVERY_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "components/devtools_discovery/devtools_target_descriptor.h" | 12 #include "components/devtools_discovery/devtools_target_descriptor.h" |
13 | 13 |
14 namespace devtools_discovery { | 14 namespace devtools_discovery { |
15 | 15 |
16 class DevToolsDiscoveryManager { | 16 class DevToolsDiscoveryManager { |
17 public: | 17 public: |
18 class Provider { | 18 class Provider { |
19 public: | 19 public: |
20 virtual ~Provider() {} | 20 virtual ~Provider() {} |
21 virtual DevToolsTargetDescriptor::List GetDescriptors() = 0; | 21 virtual DevToolsTargetDescriptor::List GetDescriptors() = 0; |
22 }; | 22 }; |
23 | 23 |
| 24 using CreateCallback = base::Callback< |
| 25 scoped_ptr<DevToolsTargetDescriptor>(const GURL& url)>; |
| 26 |
24 // Returns single instance of this class. The instance is destroyed on the | 27 // Returns single instance of this class. The instance is destroyed on the |
25 // browser main loop exit so this method MUST NOT be called after that point. | 28 // browser main loop exit so this method MUST NOT be called after that point. |
26 static DevToolsDiscoveryManager* GetInstance(); | 29 static DevToolsDiscoveryManager* GetInstance(); |
27 | 30 |
28 void AddProvider(scoped_ptr<Provider> provider); | 31 void AddProvider(scoped_ptr<Provider> provider); |
| 32 void SetCreateCallback(const CreateCallback& callback); |
29 | 33 |
30 DevToolsTargetDescriptor::List GetDescriptors(); | 34 DevToolsTargetDescriptor::List GetDescriptors(); |
| 35 scoped_ptr<DevToolsTargetDescriptor> CreateNew(const GURL& url); |
31 | 36 |
32 private: | 37 private: |
33 friend struct DefaultSingletonTraits<DevToolsDiscoveryManager>; | 38 friend struct DefaultSingletonTraits<DevToolsDiscoveryManager>; |
34 | 39 |
35 DevToolsDiscoveryManager(); | 40 DevToolsDiscoveryManager(); |
36 ~DevToolsDiscoveryManager(); | 41 ~DevToolsDiscoveryManager(); |
37 DevToolsTargetDescriptor::List GetDescriptorsFromProviders(); | 42 DevToolsTargetDescriptor::List GetDescriptorsFromProviders(); |
38 | 43 |
39 std::vector<Provider*> providers_; | 44 std::vector<Provider*> providers_; |
| 45 CreateCallback create_callback_; |
40 | 46 |
41 DISALLOW_COPY_AND_ASSIGN(DevToolsDiscoveryManager); | 47 DISALLOW_COPY_AND_ASSIGN(DevToolsDiscoveryManager); |
42 }; | 48 }; |
43 | 49 |
44 } // namespace devtools_discovery | 50 } // namespace devtools_discovery |
45 | 51 |
46 #endif // COMPONENTS_DEVTOOLS_DISCOVERY_DEVTOOLS_DISCOVERY_MANAGER_H_ | 52 #endif // COMPONENTS_DEVTOOLS_DISCOVERY_DEVTOOLS_DISCOVERY_MANAGER_H_ |
OLD | NEW |