1 // Copyright 2018 The Fuchsia Authors 2 // 3 // Use of this source code is governed by a MIT-style 4 // license that can be found in the LICENSE file or at 5 // https://opensource.org/licenses/MIT 6 7 #pragma once 8 9 #include <zircon/rights.h> 10 #include <zircon/types.h> 11 12 #include <zircon/syscalls/profile.h> 13 14 #include <fbl/canary.h> 15 #include <object/dispatcher.h> 16 17 class ProfileDispatcher final : 18 public SoloDispatcher<ProfileDispatcher, ZX_DEFAULT_PROFILE_RIGHTS> { 19 public: 20 static zx_status_t Create(const zx_profile_info_t& info, 21 fbl::RefPtr<Dispatcher>* dispatcher, 22 zx_rights_t* rights); 23 24 ~ProfileDispatcher() final; get_type()25 zx_obj_type_t get_type() const final { return ZX_OBJ_TYPE_PROFILE; } 26 27 zx_status_t ApplyProfile(fbl::RefPtr<ThreadDispatcher> thread); 28 29 private: 30 explicit ProfileDispatcher(const zx_profile_info_t& info); 31 32 fbl::Canary<fbl::magic("PROF")> canary_; 33 const zx_profile_info_t info_; 34 }; 35