ipc/chromium/src/chrome/common/notification_details.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Copyright (c) 2006-2008 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.
     5 // This file defines the type used to provide details for NotificationService
     6 // notifications.
     8 #ifndef CHROME_COMMON_NOTIFICATION_DETAILS_H__
     9 #define CHROME_COMMON_NOTIFICATION_DETAILS_H__
    11 #include "base/basictypes.h"
    13 // Do not declare a NotificationDetails directly--use either
    14 // "Details<detailsclassname>(detailsclasspointer)" or
    15 // NotificationService::NoDetails().
    16 class NotificationDetails {
    17  public:
    18   NotificationDetails() : ptr_(NULL) {}
    19   NotificationDetails(const NotificationDetails& other) : ptr_(other.ptr_) {}
    20   ~NotificationDetails() {}
    22   // NotificationDetails can be used as the index for a map; this method
    23   // returns the pointer to the current details as an identifier, for use as a
    24   // map index.
    25   uintptr_t map_key() const { return reinterpret_cast<uintptr_t>(ptr_); }
    27   bool operator!=(const NotificationDetails& other) const {
    28     return ptr_ != other.ptr_;
    29   }
    31   bool operator==(const NotificationDetails& other) const {
    32     return ptr_ == other.ptr_;
    33   }
    35  protected:
    36   NotificationDetails(void* ptr) : ptr_(ptr) {}
    38   void* ptr_;
    39 };
    41 template <class T>
    42 class Details : public NotificationDetails {
    43  public:
    44   Details(T* ptr) : NotificationDetails(ptr) {}
    45   Details(const NotificationDetails& other)
    46     : NotificationDetails(other) {}
    48   T* operator->() const { return ptr(); }
    49   T* ptr() const { return static_cast<T*>(ptr_); }
    50 };
    52 #endif  // CHROME_COMMON_NOTIFICATION_DETAILS_H__

mercurial