| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "components/devtools_discovery/devtools_target_descriptor.h" | 14 #include "content/public/browser/devtools_agent_host.h" |
| 15 | 15 |
| 16 namespace devtools_discovery { | 16 namespace devtools_discovery { |
| 17 | 17 |
| 18 class DevToolsDiscoveryManager { | 18 class DevToolsDiscoveryManager { |
| 19 public: | 19 public: |
| 20 class Provider { | 20 class Provider { |
| 21 public: | 21 public: |
| 22 virtual ~Provider() {} | 22 virtual ~Provider() {} |
| 23 | 23 |
| 24 // Caller takes ownership of created descriptors. | 24 virtual content::DevToolsAgentHost::List GetDescriptors() = 0; |
| 25 virtual DevToolsTargetDescriptor::List GetDescriptors() = 0; | |
| 26 }; | 25 }; |
| 27 | 26 |
| 28 using CreateCallback = | 27 using CreateCallback = base::Callback< |
| 29 base::Callback<std::unique_ptr<DevToolsTargetDescriptor>( | 28 scoped_refptr<content::DevToolsAgentHost>(const GURL& url)>; |
| 30 const GURL& url)>; | |
| 31 | 29 |
| 32 // Returns single instance of this class. The instance is destroyed on the | 30 // Returns single instance of this class. The instance is destroyed on the |
| 33 // browser main loop exit so this method MUST NOT be called after that point. | 31 // browser main loop exit so this method MUST NOT be called after that point. |
| 34 static DevToolsDiscoveryManager* GetInstance(); | 32 static DevToolsDiscoveryManager* GetInstance(); |
| 35 | 33 |
| 36 void AddProvider(std::unique_ptr<Provider> provider); | 34 void AddProvider(std::unique_ptr<Provider> provider); |
| 37 void SetCreateCallback(const CreateCallback& callback); | 35 void SetCreateCallback(const CreateCallback& callback); |
| 38 | |
| 39 // Caller takes ownership of created descriptors. | 36 // Caller takes ownership of created descriptors. |
| 40 DevToolsTargetDescriptor::List GetDescriptors(); | 37 content::DevToolsAgentHost::List GetDescriptors(); |
| 41 std::unique_ptr<DevToolsTargetDescriptor> CreateNew(const GURL& url); | 38 scoped_refptr<content::DevToolsAgentHost> CreateNew(const GURL& url); |
| 42 | 39 |
| 43 // Handles Browser.createTarget only. | 40 // Handles Browser.createTarget only. |
| 44 std::unique_ptr<base::DictionaryValue> HandleCreateTargetCommand( | 41 std::unique_ptr<base::DictionaryValue> HandleCreateTargetCommand( |
| 45 base::DictionaryValue* command_dict); | 42 base::DictionaryValue* command_dict); |
| 46 | 43 |
| 47 private: | 44 private: |
| 48 friend struct base::DefaultSingletonTraits<DevToolsDiscoveryManager>; | 45 friend struct base::DefaultSingletonTraits<DevToolsDiscoveryManager>; |
| 49 | 46 |
| 50 DevToolsDiscoveryManager(); | 47 DevToolsDiscoveryManager(); |
| 51 ~DevToolsDiscoveryManager(); | 48 ~DevToolsDiscoveryManager(); |
| 52 DevToolsTargetDescriptor::List GetDescriptorsFromProviders(); | 49 content::DevToolsAgentHost::List GetDescriptorsFromProviders(); |
| 53 | 50 |
| 54 std::vector<Provider*> providers_; | 51 std::vector<Provider*> providers_; |
| 55 CreateCallback create_callback_; | 52 CreateCallback create_callback_; |
| 56 | 53 |
| 57 DISALLOW_COPY_AND_ASSIGN(DevToolsDiscoveryManager); | 54 DISALLOW_COPY_AND_ASSIGN(DevToolsDiscoveryManager); |
| 58 }; | 55 }; |
| 59 | 56 |
| 60 } // namespace devtools_discovery | 57 } // namespace devtools_discovery |
| 61 | 58 |
| 62 #endif // COMPONENTS_DEVTOOLS_DISCOVERY_DEVTOOLS_DISCOVERY_MANAGER_H_ | 59 #endif // COMPONENTS_DEVTOOLS_DISCOVERY_DEVTOOLS_DISCOVERY_MANAGER_H_ |
| OLD | NEW |