1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ipc/chromium/src/chrome/common/notification_details.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,52 @@ 1.4 +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +// This file defines the type used to provide details for NotificationService 1.9 +// notifications. 1.10 + 1.11 +#ifndef CHROME_COMMON_NOTIFICATION_DETAILS_H__ 1.12 +#define CHROME_COMMON_NOTIFICATION_DETAILS_H__ 1.13 + 1.14 +#include "base/basictypes.h" 1.15 + 1.16 +// Do not declare a NotificationDetails directly--use either 1.17 +// "Details<detailsclassname>(detailsclasspointer)" or 1.18 +// NotificationService::NoDetails(). 1.19 +class NotificationDetails { 1.20 + public: 1.21 + NotificationDetails() : ptr_(NULL) {} 1.22 + NotificationDetails(const NotificationDetails& other) : ptr_(other.ptr_) {} 1.23 + ~NotificationDetails() {} 1.24 + 1.25 + // NotificationDetails can be used as the index for a map; this method 1.26 + // returns the pointer to the current details as an identifier, for use as a 1.27 + // map index. 1.28 + uintptr_t map_key() const { return reinterpret_cast<uintptr_t>(ptr_); } 1.29 + 1.30 + bool operator!=(const NotificationDetails& other) const { 1.31 + return ptr_ != other.ptr_; 1.32 + } 1.33 + 1.34 + bool operator==(const NotificationDetails& other) const { 1.35 + return ptr_ == other.ptr_; 1.36 + } 1.37 + 1.38 + protected: 1.39 + NotificationDetails(void* ptr) : ptr_(ptr) {} 1.40 + 1.41 + void* ptr_; 1.42 +}; 1.43 + 1.44 +template <class T> 1.45 +class Details : public NotificationDetails { 1.46 + public: 1.47 + Details(T* ptr) : NotificationDetails(ptr) {} 1.48 + Details(const NotificationDetails& other) 1.49 + : NotificationDetails(other) {} 1.50 + 1.51 + T* operator->() const { return ptr(); } 1.52 + T* ptr() const { return static_cast<T*>(ptr_); } 1.53 +}; 1.54 + 1.55 +#endif // CHROME_COMMON_NOTIFICATION_DETAILS_H__