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

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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