[Author: zork]
[google-gears.git] / gears / base / common / common_ff.h
blobd74d62982131d567e97077c812480d5d89e317b8
1 // Copyright 2005, Google Inc.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are met:
5 //
6 // 1. Redistributions of source code must retain the above copyright notice,
7 // this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright notice,
9 // this list of conditions and the following disclaimer in the documentation
10 // and/or other materials provided with the distribution.
11 // 3. Neither the name of Google Inc. nor the names of its contributors may be
12 // used to endorse or promote products derived from this software without
13 // specific prior written permission.
15 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef GEARS_BASE_COMMON_COMMON_FF_H__
27 #define GEARS_BASE_COMMON_COMMON_FF_H__
29 // This header file includes the more frequently used header files and defines
30 // logging primitives.
32 #define FORCE_PR_LOG
34 #include <gecko_sdk/include/prlog.h>
35 #include <gecko_sdk/include/nsStringAPI.h>
36 #include <gecko_sdk/include/nsServiceManagerUtils.h>
37 #include <gecko_sdk/include/nscore.h>
38 #include <gecko_sdk/include/nsCOMPtr.h>
39 #include <gecko_sdk/include/nsComponentManagerUtils.h>
41 #ifdef PR_LOGGING
42 extern PRLogModuleInfo *gLog;
43 #endif
44 #define LOG(args) PR_LOG(gLog, PR_LOG_DEBUG, args)
45 // Warning: never use %S in LOG(); it breaks on Linux (2- vs 4-byte wide chars)
47 //-----------------------------------------------------------------------------
48 // Debug only code to help us assert that class methods are restricted to a
49 // single thread. To use, add a DECL_SINGLE_THREAD to your class declaration.
50 // Then, add ASSERT_SINGLE_THREAD() calls to the top of each class method.
51 #ifdef DEBUG
52 #include <gecko_sdk/include/prthread.h>
53 class CurrentThreadID {
54 public:
55 CurrentThreadID() {
56 thr_ = PR_GetCurrentThread();
58 PRThread *get() {
59 return thr_;
61 private:
62 PRThread *thr_;
64 #define DECL_SINGLE_THREAD \
65 CurrentThreadID thread_id_;
66 #define ASSERT_SINGLE_THREAD() \
67 PR_ASSERT(thread_id_.get() == PR_GetCurrentThread())
68 #else
69 #define DECL_SINGLE_THREAD
70 #define ASSERT_SINGLE_THREAD()
71 #endif
73 #endif // GEARS_BASE_COMMON_COMMON_FF_H__