ipc/chromium/src/chrome/common/notification_source.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 sources for NotificationService
     6 // notifications.
     8 #ifndef CHROME_COMMON_NOTIFICATION_SOURCE_H__
     9 #define CHROME_COMMON_NOTIFICATION_SOURCE_H__
    11 #include "base/basictypes.h"
    13 // Do not declare a NotificationSource directly--use either
    14 // "Source<sourceclassname>(sourceclasspointer)" or
    15 // NotificationService::AllSources().
    16 class NotificationSource {
    17  public:
    18   NotificationSource(const NotificationSource& other) : ptr_(other.ptr_) { }
    19   ~NotificationSource() {}
    21   // NotificationSource can be used as the index for a map; this method
    22   // returns the pointer to the current source as an identifier, for use as a
    23   // map index.
    24   uintptr_t map_key() const { return reinterpret_cast<uintptr_t>(ptr_); }
    26   bool operator!=(const NotificationSource& other) const {
    27     return ptr_ != other.ptr_;
    28   }
    29   bool operator==(const NotificationSource& other) const {
    30     return ptr_ == other.ptr_;
    31   }
    33  protected:
    34   NotificationSource(void* ptr) : ptr_(ptr) {}
    36   void* ptr_;
    37 };
    39 template <class T>
    40 class Source : public NotificationSource {
    41  public:
    42   Source(T* ptr) : NotificationSource(ptr) {}
    44   Source(const NotificationSource& other)
    45     : NotificationSource(other) {}
    47   T* operator->() const { return ptr(); }
    48   T* ptr() const { return static_cast<T*>(ptr_); }
    49 };
    51 #endif  // CHROME_COMMON_NOTIFICATION_SOURCE_H__

mercurial