| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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 CHROME_BROWSER_CONFLICTS_MODULE_EVENT_SINK_IMPL_WIN_H_ |
| 6 #define CHROME_BROWSER_CONFLICTS_MODULE_EVENT_SINK_IMPL_WIN_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include "base/process/process_handle.h" |
| 11 #include "chrome/common/conflicts/module_event_sink_win.mojom.h" |
| 12 #include "content/public/common/process_type.h" |
| 13 |
| 14 class ModuleDatabase; |
| 15 |
| 16 // Implementation of the mojom::ModuleEventSink interface. This is the endpoint |
| 17 // in the browser process. This redirects calls to the singleton ModuleDatabase |
| 18 // object. |
| 19 class ModuleEventSinkImpl : public mojom::ModuleEventSink { |
| 20 public: |
| 21 // Creates a service endpoint that forwards notifications from the remote |
| 22 // |process| of the provided |process_type| to the provided |module_database|. |
| 23 // The |module_database| must outlive this object. |
| 24 ModuleEventSinkImpl(base::ProcessHandle process, |
| 25 content::ProcessType process_type, |
| 26 ModuleDatabase* module_database); |
| 27 ~ModuleEventSinkImpl() override; |
| 28 |
| 29 // Factory function for use with service_manager::InterfaceRegistry. This |
| 30 // creates a concrete implementation of mojom::ModuleDatabase interface in the |
| 31 // current process, for the remote process represented by the provided |
| 32 // |request|. This should only be called on the UI thread. |
| 33 static void Create(base::ProcessHandle process, |
| 34 content::ProcessType process_type, |
| 35 ModuleDatabase* module_database, |
| 36 mojom::ModuleEventSinkRequest request); |
| 37 |
| 38 // mojom::ModuleEventSink implementation: |
| 39 void OnModuleEvent(mojom::ModuleEventType event_type, |
| 40 uint64_t load_address) override; |
| 41 |
| 42 bool in_error() const { return in_error_; } |
| 43 |
| 44 private: |
| 45 friend class ModuleEventSinkImplTest; |
| 46 |
| 47 // OnModuleEvent disptaches to these two functions depending on the event |
| 48 // type. |
| 49 void OnModuleLoad(uint64_t load_address); |
| 50 void OnModuleUnload(uint64_t load_address); |
| 51 |
| 52 // A handle to the process on the other side of the pipe. |
| 53 base::ProcessHandle process_; |
| 54 |
| 55 // The module database this forwards events to. The |module_database| must |
| 56 // outlive this object. |
| 57 ModuleDatabase* module_database_; |
| 58 |
| 59 // The process ID of the remote process on the other end of the pipe. This is |
| 60 // forwarded along to the ModuleDatabase for each call. |
| 61 uint32_t process_id_; |
| 62 |
| 63 // The creation time of the process. Combined with process_id_ this uniquely |
| 64 // identifies a process. |
| 65 uint64_t creation_time_; |
| 66 |
| 67 // Indicates whether or not this connection is in an error mode. If true then |
| 68 // all communication from the remote client is silently dropped. |
| 69 bool in_error_; |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(ModuleEventSinkImpl); |
| 72 }; |
| 73 |
| 74 #endif // CHROME_BROWSER_CONFLICTS_MODULE_EVENT_SINK_IMPL_WIN_H_ |
| OLD | NEW |