From 474d68791965f20f8e0dfa2bfb4d87300f1f29e0 Mon Sep 17 00:00:00 2001 From: Jim Van Verth Date: Thu, 14 Dec 2017 13:00:05 -0500 Subject: Send TextBlobCache purge messages only to owning cache. Bug: 703297 Change-Id: I95cdaa5bdebadd5ce88ae3ee468c59baa08353c6 Reviewed-on: https://skia-review.googlesource.com/85046 Reviewed-by: Brian Salomon Commit-Queue: Jim Van Verth --- include/private/SkMessageBus.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'include/private/SkMessageBus.h') diff --git a/include/private/SkMessageBus.h b/include/private/SkMessageBus.h index 79f5c026dc..6ddf82c446 100644 --- a/include/private/SkMessageBus.h +++ b/include/private/SkMessageBus.h @@ -17,12 +17,14 @@ template class SkMessageBus : SkNoncopyable { public: - // Post a message to be received by all Inboxes for this Message type. Threadsafe. - static void Post(const Message& m); + // Post a message to be received by Inboxes for this Message type. Threadsafe. + // If id is SK_InvalidUniqueID then it will be sent to all inboxes. + // Otherwise it will be sent to the inbox with that id. + static void Post(const Message& m, uint32_t destID = SK_InvalidUniqueID); class Inbox { public: - Inbox(); + Inbox(uint32_t uniqueID = SK_InvalidUniqueID); ~Inbox(); // Overwrite out with all the messages we've received since the last call. Threadsafe. @@ -31,6 +33,7 @@ public: private: SkTArray fMessages; SkMutex fMessagesMutex; + uint32_t fUniqueID; friend class SkMessageBus; void receive(const Message& m); // SkMessageBus is a friend only to call this. @@ -58,7 +61,7 @@ private: // ----------------------- Implementation of SkMessageBus::Inbox ----------------------- template -SkMessageBus::Inbox::Inbox() { +SkMessageBus::Inbox::Inbox(uint32_t uniqueID) : fUniqueID(uniqueID) { // Register ourselves with the corresponding message bus. SkMessageBus* bus = SkMessageBus::Get(); SkAutoMutexAcquire lock(bus->fInboxesMutex); @@ -99,11 +102,13 @@ template SkMessageBus::SkMessageBus() {} template -/*static*/ void SkMessageBus::Post(const Message& m) { +/*static*/ void SkMessageBus::Post(const Message& m, uint32_t destID) { SkMessageBus* bus = SkMessageBus::Get(); SkAutoMutexAcquire lock(bus->fInboxesMutex); for (int i = 0; i < bus->fInboxes.count(); i++) { - bus->fInboxes[i]->receive(m); + if (SK_InvalidUniqueID == destID || bus->fInboxes[i]->fUniqueID == destID) { + bus->fInboxes[i]->receive(m); + } } } -- cgit v1.2.3