| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 CHROME_BROWSER_CONFLICTS_MODULE_EVENT_SINK_IMPL_WIN_H_ | 5 #ifndef CHROME_BROWSER_CONFLICTS_MODULE_EVENT_SINK_IMPL_WIN_H_ |
| 6 #define CHROME_BROWSER_CONFLICTS_MODULE_EVENT_SINK_IMPL_WIN_H_ | 6 #define CHROME_BROWSER_CONFLICTS_MODULE_EVENT_SINK_IMPL_WIN_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/process/process_handle.h" | 11 #include "base/process/process_handle.h" |
| 12 #include "chrome/common/conflicts/module_event_sink_win.mojom.h" | 12 #include "chrome/common/conflicts/module_event_sink_win.mojom.h" |
| 13 #include "content/public/common/process_type.h" | 13 #include "content/public/common/process_type.h" |
| 14 #include "services/service_manager/public/cpp/bind_source_info.h" |
| 14 | 15 |
| 15 class ModuleDatabase; | 16 class ModuleDatabase; |
| 16 | 17 |
| 17 // Implementation of the mojom::ModuleEventSink interface. This is the endpoint | 18 // Implementation of the mojom::ModuleEventSink interface. This is the endpoint |
| 18 // in the browser process. This redirects calls to the singleton ModuleDatabase | 19 // in the browser process. This redirects calls to the singleton ModuleDatabase |
| 19 // object. | 20 // object. |
| 20 class ModuleEventSinkImpl : public mojom::ModuleEventSink { | 21 class ModuleEventSinkImpl : public mojom::ModuleEventSink { |
| 21 public: | 22 public: |
| 22 // Callback for retrieving the handle associated with a process. This is used | 23 // Callback for retrieving the handle associated with a process. This is used |
| 23 // by "Create" to get a handle to the remote process. | 24 // by "Create" to get a handle to the remote process. |
| 24 using GetProcessHandleCallback = base::Callback<base::ProcessHandle()>; | 25 using GetProcessHandleCallback = base::Callback<base::ProcessHandle()>; |
| 25 | 26 |
| 26 // Creates a service endpoint that forwards notifications from the remote | 27 // Creates a service endpoint that forwards notifications from the remote |
| 27 // |process| of the provided |process_type| to the provided |module_database|. | 28 // |process| of the provided |process_type| to the provided |module_database|. |
| 28 // The |module_database| must outlive this object. | 29 // The |module_database| must outlive this object. |
| 29 ModuleEventSinkImpl(base::ProcessHandle process, | 30 ModuleEventSinkImpl(base::ProcessHandle process, |
| 30 content::ProcessType process_type, | 31 content::ProcessType process_type, |
| 31 ModuleDatabase* module_database); | 32 ModuleDatabase* module_database); |
| 32 ~ModuleEventSinkImpl() override; | 33 ~ModuleEventSinkImpl() override; |
| 33 | 34 |
| 34 // Factory function for use with service_manager::InterfaceRegistry. This | 35 // Factory function for use with service_manager::InterfaceRegistry. This |
| 35 // creates a concrete implementation of mojom::ModuleDatabase interface in the | 36 // creates a concrete implementation of mojom::ModuleDatabase interface in the |
| 36 // current process, for the remote process represented by the provided | 37 // current process, for the remote process represented by the provided |
| 37 // |request|. This should only be called on the UI thread. | 38 // |request|. This should only be called on the UI thread. |
| 38 static void Create(GetProcessHandleCallback get_process_handle, | 39 static void Create(GetProcessHandleCallback get_process_handle, |
| 39 content::ProcessType process_type, | 40 content::ProcessType process_type, |
| 40 ModuleDatabase* module_database, | 41 ModuleDatabase* module_database, |
| 42 const service_manager::BindSourceInfo& source_info, |
| 41 mojom::ModuleEventSinkRequest request); | 43 mojom::ModuleEventSinkRequest request); |
| 42 | 44 |
| 43 // mojom::ModuleEventSink implementation: | 45 // mojom::ModuleEventSink implementation: |
| 44 void OnModuleEvent(mojom::ModuleEventType event_type, | 46 void OnModuleEvent(mojom::ModuleEventType event_type, |
| 45 uint64_t load_address) override; | 47 uint64_t load_address) override; |
| 46 | 48 |
| 47 bool in_error() const { return in_error_; } | 49 bool in_error() const { return in_error_; } |
| 48 | 50 |
| 49 // Gets the process creation time associated with the given process. | 51 // Gets the process creation time associated with the given process. |
| 50 static bool GetProcessCreationTime(base::ProcessHandle process, | 52 static bool GetProcessCreationTime(base::ProcessHandle process, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 74 uint64_t creation_time_; | 76 uint64_t creation_time_; |
| 75 | 77 |
| 76 // Indicates whether or not this connection is in an error mode. If true then | 78 // Indicates whether or not this connection is in an error mode. If true then |
| 77 // all communication from the remote client is silently dropped. | 79 // all communication from the remote client is silently dropped. |
| 78 bool in_error_; | 80 bool in_error_; |
| 79 | 81 |
| 80 DISALLOW_COPY_AND_ASSIGN(ModuleEventSinkImpl); | 82 DISALLOW_COPY_AND_ASSIGN(ModuleEventSinkImpl); |
| 81 }; | 83 }; |
| 82 | 84 |
| 83 #endif // CHROME_BROWSER_CONFLICTS_MODULE_EVENT_SINK_IMPL_WIN_H_ | 85 #endif // CHROME_BROWSER_CONFLICTS_MODULE_EVENT_SINK_IMPL_WIN_H_ |
| OLD | NEW |