~ubuntu-branches/ubuntu/utopic/rlvm/utopic-proposed

« back to all changes in this revision

Viewing changes to src/base/notification_source.h

  • Committer: Bazaar Package Importer
  • Author(s): Ying-Chun Liu (PaulLiu), Ying-Chun Liu (PaulLiu), Elliot Glaysher
  • Date: 2011-05-19 00:28:44 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20110519002844-qszwmj7oiixww0eg
Tags: 0.12-1
[ Ying-Chun Liu (PaulLiu) <paulliu@debian.org> ]
* New upstream release

[ Elliot Glaysher <glaysher@umich.edu> ]
* New GTK+ interface with desktop integration and UI refinements
* Partial Japanese localizations
* Fix graphics corruption in in-game dialogs when a dialog is brought
  up, and then fullscreen mode activated
* Smooth the output of text in rlBabel using games
* Don't play voice samples while fast forwarding

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) 2011 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.
 
4
 
 
5
// This file defines the type used to provide sources for NotificationService
 
6
// notifications.
 
7
 
 
8
#ifndef CONTENT_COMMON_NOTIFICATION_SOURCE_H_
 
9
#define CONTENT_COMMON_NOTIFICATION_SOURCE_H_
 
10
#pragma once
 
11
 
 
12
#include <stdint.h>
 
13
 
 
14
// Do not declare a NotificationSource directly--use either
 
15
// "Source<sourceclassname>(sourceclasspointer)" or
 
16
// NotificationService::AllSources().
 
17
class NotificationSource {
 
18
 public:
 
19
  NotificationSource(const NotificationSource& other);
 
20
  ~NotificationSource();
 
21
 
 
22
  // NotificationSource can be used as the index for a map; this method
 
23
  // returns the pointer to the current source as an identifier, for use as a
 
24
  // map index.
 
25
  uintptr_t map_key() const { return reinterpret_cast<uintptr_t>(ptr_); }
 
26
 
 
27
  bool operator!=(const NotificationSource& other) const {
 
28
    return ptr_ != other.ptr_;
 
29
  }
 
30
  bool operator==(const NotificationSource& other) const {
 
31
    return ptr_ == other.ptr_;
 
32
  }
 
33
 
 
34
 protected:
 
35
  explicit NotificationSource(const void* ptr);
 
36
 
 
37
  // Declaring this const allows Source<T> to be used with both T = Foo and
 
38
  // T = const Foo.
 
39
  const void* ptr_;
 
40
};
 
41
 
 
42
template <class T>
 
43
class Source : public NotificationSource {
 
44
 public:
 
45
  // TODO(erg): Our code hard relies on implicit conversion
 
46
  Source(const T* ptr) : NotificationSource(ptr) {}  // NOLINT
 
47
  Source(const NotificationSource& other)      // NOLINT
 
48
    : NotificationSource(other) {}
 
49
 
 
50
  T* operator->() const { return ptr(); }
 
51
  // The casts here allow this to compile with both T = Foo and T = const Foo.
 
52
  T* ptr() const { return static_cast<T*>(const_cast<void*>(ptr_)); }
 
53
};
 
54
 
 
55
#endif  // CONTENT_COMMON_NOTIFICATION_SOURCE_H_