diff options
46 files changed, 434 insertions, 389 deletions
diff --git a/base/at_exit.h b/base/at_exit.h index fa0f277..35c96b9 100644 --- a/base/at_exit.h +++ b/base/at_exit.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -28,13 +28,6 @@ namespace base { // callbacks and singleton destructors will be called. class AtExitManager { - protected: - // This constructor will allow this instance of AtExitManager to be created - // even if one already exists. This should only be used for testing! - // AtExitManagers are kept on a global stack, and it will be removed during - // destruction. This allows you to shadow another AtExitManager. - explicit AtExitManager(bool shadow); - public: typedef void (*AtExitCallbackType)(void*); @@ -52,6 +45,13 @@ class AtExitManager { // is possible to register new callbacks after calling this function. static void ProcessCallbacksNow(); + protected: + // This constructor will allow this instance of AtExitManager to be created + // even if one already exists. This should only be used for testing! + // AtExitManagers are kept on a global stack, and it will be removed during + // destruction. This allows you to shadow another AtExitManager. + explicit AtExitManager(bool shadow); + private: struct CallbackAndParam { CallbackAndParam(AtExitCallbackType func, void* param) diff --git a/base/base.gypi b/base/base.gypi index 3d650dc..f241967a 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -147,6 +147,7 @@ 'path_service.h', 'pickle.cc', 'pickle.h', + 'platform_file.cc', 'platform_file.h', 'platform_file_posix.cc', 'platform_file_win.cc', diff --git a/base/command_line.h b/base/command_line.h index 0e6ac26..b8bbba9 100644 --- a/base/command_line.h +++ b/base/command_line.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -29,36 +29,44 @@ class InProcessBrowserTest; class CommandLine { public: +#if defined(OS_WIN) + // The type of native command line arguments. + typedef std::wstring StringType; +#elif defined(OS_POSIX) + // The type of native command line arguments. + typedef std::string StringType; +#endif + + // The type of map for parsed-out switch key and values. + typedef std::map<std::string, StringType> SwitchMap; + // A constructor for CommandLines that are used only to carry switches and // arguments. enum NoProgram { NO_PROGRAM }; explicit CommandLine(NoProgram no_program); + + // Construct a new, empty command line. + // |program| is the name of the program to run (aka argv[0]). + explicit CommandLine(const FilePath& program); + +#if defined(OS_POSIX) + CommandLine(int argc, const char* const* argv); + explicit CommandLine(const std::vector<std::string>& argv); +#endif + ~CommandLine(); #if defined(OS_WIN) - // The type of native command line arguments. - typedef std::wstring StringType; - // Initialize by parsing the given command-line string. // The program name is assumed to be the first item in the string. void ParseFromString(const std::wstring& command_line); static CommandLine FromString(const std::wstring& command_line); #elif defined(OS_POSIX) - // The type of native command line arguments. - typedef std::string StringType; - // Initialize from an argv vector. void InitFromArgv(int argc, const char* const* argv); void InitFromArgv(const std::vector<std::string>& argv); - - CommandLine(int argc, const char* const* argv); - explicit CommandLine(const std::vector<std::string>& argv); #endif - // Construct a new, empty command line. - // |program| is the name of the program to run (aka argv[0]). - explicit CommandLine(const FilePath& program); - // Initialize the current process CommandLine singleton. On Windows, // ignores its arguments (we instead parse GetCommandLineW() // directly) because we don't trust the CRT's parsing of the command @@ -91,9 +99,6 @@ class CommandLine { // Get the number of switches in this process. size_t GetSwitchCount() const { return switches_.size(); } - // The type of map for parsed-out switch key and values. - typedef std::map<std::string, StringType> SwitchMap; - // Get a copy of all switches, along with their values const SwitchMap& GetSwitches() const { return switches_; @@ -161,6 +166,12 @@ class CommandLine { // Used by InProcessBrowserTest. static CommandLine* ForCurrentProcessMutable(); + // Returns true and fills in |switch_string| and |switch_value| + // if |parameter_string| represents a switch. + static bool IsSwitch(const StringType& parameter_string, + std::string* switch_string, + StringType* switch_value); + // The singleton CommandLine instance representing the current process's // command line. static CommandLine* current_process_commandline_; @@ -178,12 +189,6 @@ class CommandLine { std::vector<std::string> argv_; #endif - // Returns true and fills in |switch_string| and |switch_value| - // if |parameter_string| represents a switch. - static bool IsSwitch(const StringType& parameter_string, - std::string* switch_string, - StringType* switch_value); - // Parsed-out values. SwitchMap switches_; diff --git a/base/crypto/rsa_private_key.h b/base/crypto/rsa_private_key.h index bac4250..9b8b4fd 100644 --- a/base/crypto/rsa_private_key.h +++ b/base/crypto/rsa_private_key.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -168,6 +168,8 @@ class PrivateKeyInfoCodec { // TODO(hclam): This class should be ref-counted so it can be reused easily. class RSAPrivateKey { public: + ~RSAPrivateKey(); + // Create a new random instance. Can return NULL if initialization fails. static RSAPrivateKey* Create(uint16 num_bits); @@ -203,8 +205,6 @@ class RSAPrivateKey { static RSAPrivateKey* FindFromPublicKeyInfo( const std::vector<uint8>& input); - ~RSAPrivateKey(); - #if defined(USE_OPENSSL) EVP_PKEY* key() { return key_; } #elif defined(USE_NSS) diff --git a/base/crypto/signature_creator.h b/base/crypto/signature_creator.h index c405560..3e3afd2 100644 --- a/base/crypto/signature_creator.h +++ b/base/crypto/signature_creator.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -33,12 +33,12 @@ namespace base { // Currently can only sign data using SHA-1 with RSA encryption. class SignatureCreator { public: + ~SignatureCreator(); + // Create an instance. The caller must ensure that the provided PrivateKey // instance outlives the created SignatureCreator. static SignatureCreator* Create(RSAPrivateKey* key); - ~SignatureCreator(); - // Update the signature with more data. bool Update(const uint8* data_part, int data_part_len); diff --git a/base/file_util.h b/base/file_util.h index e34d0de..ab6906d 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -462,10 +462,10 @@ class FileEnumerator { WIN32_FIND_DATA find_data_; HANDLE find_handle_; #elif defined(OS_POSIX) - typedef struct { + struct DirectoryEntryInfo { FilePath filename; struct stat stat; - } DirectoryEntryInfo; + }; // Read the filenames in source into the vector of DirectoryEntryInfo's static bool ReadDirectory(std::vector<DirectoryEntryInfo>* entries, diff --git a/base/file_util_proxy.h b/base/file_util_proxy.h index f266562..4181a26 100644 --- a/base/file_util_proxy.h +++ b/base/file_util_proxy.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -33,14 +33,27 @@ class FileUtilProxy { // StatusCallback, in which case the operation will complete silently. typedef Callback1<PlatformFileError /* error code */>::Type StatusCallback; + typedef Callback3<PlatformFileError /* error code */, + PassPlatformFile, + bool /* created */>::Type CreateOrOpenCallback; + typedef Callback3<PlatformFileError /* error code */, + PassPlatformFile, + FilePath>::Type CreateTemporaryCallback; + typedef Callback2<PlatformFileError /* error code */, + bool /* created */>::Type EnsureFileExistsCallback; + typedef Callback2<PlatformFileError /* error code */, + const PlatformFileInfo& /* file_info */ + >::Type GetFileInfoCallback; + typedef Callback2<PlatformFileError /* error code */, + const std::vector<Entry>&>::Type ReadDirectoryCallback; + typedef Callback2<PlatformFileError /* error code */, + int /* bytes read/written */>::Type ReadWriteCallback; + // Creates or opens a file with the given flags. It is invalid to pass NULL // for the callback. // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create // a new file at the given |file_path| and calls back with // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists. - typedef Callback3<PlatformFileError /* error code */, - PassPlatformFile, - bool /* created */>::Type CreateOrOpenCallback; static bool CreateOrOpen(scoped_refptr<MessageLoopProxy> message_loop_proxy, const FilePath& file_path, int file_flags, @@ -48,9 +61,6 @@ class FileUtilProxy { // Creates a temporary file for writing. The path and an open file handle // are returned. It is invalid to pass NULL for the callback. - typedef Callback3<PlatformFileError /* error code */, - PassPlatformFile, - FilePath>::Type CreateTemporaryCallback; static bool CreateTemporary( scoped_refptr<MessageLoopProxy> message_loop_proxy, CreateTemporaryCallback* callback); @@ -69,8 +79,6 @@ class FileUtilProxy { // is set PLATFORM_FILE_OK. // If the file hasn't existed but it couldn't be created for some other // reasons, |created| is set false and |error code| indicates the error. - typedef Callback2<PlatformFileError /* error code */, - bool /* created */>::Type EnsureFileExistsCallback; static bool EnsureFileExists( scoped_refptr<MessageLoopProxy> message_loop_proxy, const FilePath& file_path, @@ -78,9 +86,6 @@ class FileUtilProxy { // Retrieves the information about a file. It is invalid to pass NULL for the // callback. - typedef Callback2<PlatformFileError /* error code */, - const PlatformFileInfo& /* file_info */ - >::Type GetFileInfoCallback; static bool GetFileInfo( scoped_refptr<MessageLoopProxy> message_loop_proxy, const FilePath& file_path, @@ -91,8 +96,6 @@ class FileUtilProxy { PlatformFile file, GetFileInfoCallback* callback); - typedef Callback2<PlatformFileError /* error code */, - const std::vector<Entry>&>::Type ReadDirectoryCallback; static bool ReadDirectory(scoped_refptr<MessageLoopProxy> message_loop_proxy, const FilePath& file_path, ReadDirectoryCallback* callback); @@ -142,8 +145,6 @@ class FileUtilProxy { // Reads from a file. On success, the file pointer is moved to position // |offset + bytes_to_read| in the file. The callback can be NULL. - typedef Callback2<PlatformFileError /* error code */, - int /* bytes read/written */>::Type ReadWriteCallback; static bool Read( scoped_refptr<MessageLoopProxy> message_loop_proxy, PlatformFile file, diff --git a/base/global_descriptors_posix.h b/base/global_descriptors_posix.h index ab2b86b..0cb5b4f 100644 --- a/base/global_descriptors_posix.h +++ b/base/global_descriptors_posix.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -37,6 +37,8 @@ namespace base { class GlobalDescriptors { public: typedef uint32_t Key; + typedef std::vector<std::pair<Key, int> > Mapping; + // Often we want a canonical descriptor for a given Key. In this case, we add // the following constant to the key value: static const int kBaseDescriptor = 3; // 0, 1, 2 are already taken. @@ -46,11 +48,10 @@ class GlobalDescriptors { // Get a descriptor given a key. It is a fatal error if the key is not known. int Get(Key key) const; + // Get a descriptor give a key. Returns -1 on error. int MaybeGet(Key key) const; - typedef std::vector<std::pair<Key, int> > Mapping; - // Set the descriptor for the given key. void Set(Key key, int fd); @@ -59,9 +60,9 @@ class GlobalDescriptors { } private: + friend struct DefaultSingletonTraits<GlobalDescriptors>; GlobalDescriptors(); ~GlobalDescriptors(); - friend struct DefaultSingletonTraits<GlobalDescriptors>; Mapping descriptors_; }; diff --git a/base/json/json_reader.h b/base/json/json_reader.h index 33bd8f2..77c4e74 100644 --- a/base/json/json_reader.h +++ b/base/json/json_reader.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -69,6 +69,11 @@ class JSONReader { Token(Type t, const wchar_t* b, int len) : type(t), begin(b), length(len) {} + // Get the character that's one past the end of this token. + wchar_t NextChar() { + return *(begin + length); + } + Type type; // A pointer into JSONReader::json_pos_ that's the beginning of this token. @@ -76,11 +81,6 @@ class JSONReader { // End should be one char past the end of the token. int length; - - // Get the character that's one past the end of this token. - wchar_t NextChar() { - return *(begin + length); - } }; // Error codes during parsing. diff --git a/base/logging.h b/base/logging.h index 6689eec..a097568 100644 --- a/base/logging.h +++ b/base/logging.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -803,11 +803,11 @@ class Win32ErrorLogMessage { LogSeverity severity, SystemErrorCode err); - std::ostream& stream() { return log_message_.stream(); } - // Appends the error message before destructing the encapsulated class. ~Win32ErrorLogMessage(); + std::ostream& stream() { return log_message_.stream(); } + private: SystemErrorCode err_; // Optional name of the module defining the error. @@ -825,11 +825,11 @@ class ErrnoLogMessage { LogSeverity severity, SystemErrorCode err); - std::ostream& stream() { return log_message_.stream(); } - // Appends the error message before destructing the encapsulated class. ~ErrnoLogMessage(); + std::ostream& stream() { return log_message_.stream(); } + private: SystemErrorCode err_; LogMessage log_message_; diff --git a/base/message_loop.h b/base/message_loop.h index a5a94bc..8058e24 100644 --- a/base/message_loop.h +++ b/base/message_loop.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -66,24 +66,43 @@ class Histogram; // class MessageLoop : public base::MessagePump::Delegate { public: - // A TaskObserver is an object that receives task notifications from the - // MessageLoop. - // - // NOTE: A TaskObserver implementation should be extremely fast! - class TaskObserver { - public: - TaskObserver(); - - // This method is called before processing a task. - virtual void WillProcessTask(const Task* task) = 0; - - // This method is called after processing a task. - virtual void DidProcessTask(const Task* task) = 0; +#if defined(OS_WIN) + typedef base::MessagePumpWin::Dispatcher Dispatcher; + typedef base::MessagePumpForUI::Observer Observer; +#elif !defined(OS_MACOSX) +#if defined(TOUCH_UI) + typedef base::MessagePumpGlibXDispatcher Dispatcher; +#else + typedef base::MessagePumpForUI::Dispatcher Dispatcher; +#endif + typedef base::MessagePumpForUI::Observer Observer; +#endif - protected: - virtual ~TaskObserver(); + // A MessageLoop has a particular type, which indicates the set of + // asynchronous events it may process in addition to tasks and timers. + // + // TYPE_DEFAULT + // This type of ML only supports tasks and timers. + // + // TYPE_UI + // This type of ML also supports native UI events (e.g., Windows messages). + // See also MessageLoopForUI. + // + // TYPE_IO + // This type of ML also supports asynchronous IO. See also + // MessageLoopForIO. + // + enum Type { + TYPE_DEFAULT, + TYPE_UI, + TYPE_IO }; + // Normally, it is not necessary to instantiate a MessageLoop. Instead, it + // is typical to make use of the current thread's MessageLoop instance. + explicit MessageLoop(Type type = TYPE_DEFAULT); + ~MessageLoop(); + static void EnableHistogrammer(bool enable_histogrammer); // A DestructionObserver is notified when the current MessageLoop is being @@ -200,31 +219,6 @@ class MessageLoop : public base::MessagePump::Delegate { } }; - // A MessageLoop has a particular type, which indicates the set of - // asynchronous events it may process in addition to tasks and timers. - // - // TYPE_DEFAULT - // This type of ML only supports tasks and timers. - // - // TYPE_UI - // This type of ML also supports native UI events (e.g., Windows messages). - // See also MessageLoopForUI. - // - // TYPE_IO - // This type of ML also supports asynchronous IO. See also - // MessageLoopForIO. - // - enum Type { - TYPE_DEFAULT, - TYPE_UI, - TYPE_IO - }; - - // Normally, it is not necessary to instantiate a MessageLoop. Instead, it - // is typical to make use of the current thread's MessageLoop instance. - explicit MessageLoop(Type type = TYPE_DEFAULT); - ~MessageLoop(); - // Returns the type passed to the constructor. Type type() const { return type_; } @@ -284,23 +278,29 @@ class MessageLoop : public base::MessagePump::Delegate { // Returns true if we are currently running a nested message loop. bool IsNested(); + // A TaskObserver is an object that receives task notifications from the + // MessageLoop. + // + // NOTE: A TaskObserver implementation should be extremely fast! + class TaskObserver { + public: + TaskObserver(); + + // This method is called before processing a task. + virtual void WillProcessTask(const Task* task) = 0; + + // This method is called after processing a task. + virtual void DidProcessTask(const Task* task) = 0; + + protected: + virtual ~TaskObserver(); + }; + // These functions can only be called on the same thread that |this| is // running on. void AddTaskObserver(TaskObserver* task_observer); void RemoveTaskObserver(TaskObserver* task_observer); -#if defined(OS_WIN) - typedef base::MessagePumpWin::Dispatcher Dispatcher; - typedef base::MessagePumpForUI::Observer Observer; -#elif !defined(OS_MACOSX) -#if defined(TOUCH_UI) - typedef base::MessagePumpGlibXDispatcher Dispatcher; -#else - typedef base::MessagePumpForUI::Dispatcher Dispatcher; -#endif - typedef base::MessagePumpForUI::Observer Observer; -#endif - // Returns true if the message loop has high resolution timers enabled. // Provided for testing. bool high_resolution_timers_enabled() { @@ -341,17 +341,17 @@ class MessageLoop : public base::MessagePump::Delegate { // This structure is copied around by value. struct PendingTask { - Task* task; // The task to run. - base::TimeTicks delayed_run_time; // The time when the task should be run. - int sequence_num; // Secondary sort key for run time. - bool nestable; // OK to dispatch from a nested loop. - PendingTask(Task* task, bool nestable) : task(task), sequence_num(0), nestable(nestable) { } // Used to support sorting. bool operator<(const PendingTask& other) const; + + Task* task; // The task to run. + base::TimeTicks delayed_run_time; // The time when the task should be run. + int sequence_num; // Secondary sort key for run time. + bool nestable; // OK to dispatch from a nested loop. }; class TaskQueue : public std::queue<PendingTask> { @@ -427,11 +427,6 @@ class MessageLoop : public base::MessagePump::Delegate { void PostTask_Helper(const tracked_objects::Location& from_here, Task* task, int64 delay_ms, bool nestable); - // base::MessagePump::Delegate methods: - virtual bool DoWork(); - virtual bool DoDelayedWork(base::TimeTicks* next_delayed_work_time); - virtual bool DoIdleWork(); - // Start recording histogram info about events and action IF it was enabled // and IF the statistics recorder can accept a registration of our histogram. void StartHistogrammer(); @@ -441,6 +436,11 @@ class MessageLoop : public base::MessagePump::Delegate { // If message_histogram_ is NULL, this is a no-op. void HistogramEvent(int event); + // base::MessagePump::Delegate methods: + virtual bool DoWork(); + virtual bool DoDelayedWork(base::TimeTicks* next_delayed_work_time); + virtual bool DoIdleWork(); + Type type_; // A list of tasks that need to be processed by this instance. Note that diff --git a/base/message_pump_glib.h b/base/message_pump_glib.h index c118155..70bf108 100644 --- a/base/message_pump_glib.h +++ b/base/message_pump_glib.h @@ -1,4 +1,4 @@ -// Copyright (c) 2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -62,11 +62,6 @@ class MessagePumpForUI : public MessagePump { // is ready for processing. virtual bool RunOnce(GMainContext* context, bool block); - virtual void Run(Delegate* delegate); - virtual void Quit(); - virtual void ScheduleWork(); - virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time); - // Internal methods used for processing the pump callbacks. They are // public for simplicity but should not be used directly. HandlePrepare // is called during the prepare step of glib, and returns a timeout that @@ -88,6 +83,12 @@ class MessagePumpForUI : public MessagePump { // some task before/after calling the default handler (EventDispatcher). virtual void DispatchEvents(GdkEvent* event); + // Overridden from MessagePump: + virtual void Run(Delegate* delegate); + virtual void Quit(); + virtual void ScheduleWork(); + virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time); + protected: // Returns the dispatcher for the current run state (|state_->dispatcher|). Dispatcher* GetDispatcher(); diff --git a/base/message_pump_glib_x.h b/base/message_pump_glib_x.h index fc3f3b1..e94b797 100644 --- a/base/message_pump_glib_x.h +++ b/base/message_pump_glib_x.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -22,9 +22,6 @@ class MessagePumpGlibX : public MessagePumpForUI { MessagePumpGlibX(); virtual ~MessagePumpGlibX(); - // MessagePumpForUI implementation. - virtual bool RunOnce(GMainContext* context, bool block); - // Indicates whether a GDK event was injected by chrome (when |true|) or if it // was captured and being processed by GDK (when |false|). bool IsDispatchingEvent(void) { return dispatching_event_; } @@ -34,6 +31,9 @@ class MessagePumpGlibX : public MessagePumpForUI { void SetupXInput2ForXWindow(Window xid); #endif + // Overridden from MessagePumpForUI: + virtual bool RunOnce(GMainContext* context, bool block); + private: static void EventDispatcherX(GdkEvent* event, gpointer data); diff --git a/base/message_pump_glib_x_dispatch.h b/base/message_pump_glib_x_dispatch.h index faee5b5..4a973726 100644 --- a/base/message_pump_glib_x_dispatch.h +++ b/base/message_pump_glib_x_dispatch.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -18,13 +18,12 @@ namespace base { // GdkEvents. This class provides additional mechanism for dispatching XEvents. class MessagePumpGlibXDispatcher : public MessagePumpForUI::Dispatcher { public: - - typedef enum { + enum DispatchStatus { EVENT_IGNORED, // The event was not processed. EVENT_PROCESSED, // The event has been processed. EVENT_QUIT // The event was processed and the message-loop should // terminate. - } DispatchStatus; + }; // Dispatches the event. EVENT_IGNORED is returned if the event was ignored // (i.e. not processed). EVENT_PROCESSED is returned if the event was diff --git a/base/message_pump_libevent.h b/base/message_pump_libevent.h index d8d000d..2ade511 100644 --- a/base/message_pump_libevent.h +++ b/base/message_pump_libevent.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -86,15 +86,15 @@ class MessagePumpLibevent : public MessagePump { DISALLOW_COPY_AND_ASSIGN(FileDescriptorWatcher); }; - MessagePumpLibevent(); - virtual ~MessagePumpLibevent(); - enum Mode { WATCH_READ = 1 << 0, WATCH_WRITE = 1 << 1, WATCH_READ_WRITE = WATCH_READ | WATCH_WRITE }; + MessagePumpLibevent(); + virtual ~MessagePumpLibevent(); + // Have the current thread's message loop watch for a a situation in which // reading/writing to the FD can be performed without blocking. // Callers must provide a preallocated FileDescriptorWatcher object which @@ -128,6 +128,14 @@ class MessagePumpLibevent : public MessagePump { // Risky part of constructor. Returns true on success. bool Init(); + // Called by libevent to tell us a registered FD can be read/written to. + static void OnLibeventNotification(int fd, short flags, + void* context); + + // Unix pipe used to implement ScheduleWork() + // ... callback; called by libevent inside Run() when pipe is ready to read + static void OnWakeup(int socket, short flags, void* context); + // This flag is set to false when Run should return. bool keep_running_; @@ -141,13 +149,6 @@ class MessagePumpLibevent : public MessagePump { // readiness callbacks when a socket is ready for I/O. event_base* event_base_; - // Called by libevent to tell us a registered FD can be read/written to. - static void OnLibeventNotification(int fd, short flags, - void* context); - - // Unix pipe used to implement ScheduleWork() - // ... callback; called by libevent inside Run() when pipe is ready to read - static void OnWakeup(int socket, short flags, void* context); // ... write end; ScheduleWork() writes a single byte to it int wakeup_pipe_in_; // ... read end; OnWakeup reads it and then breaks Run() out of its sleep diff --git a/base/metrics/field_trial.h b/base/metrics/field_trial.h index 1f0af9e..8902077 100644 --- a/base/metrics/field_trial.h +++ b/base/metrics/field_trial.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -217,12 +217,12 @@ class FieldTrialList { static size_t GetFieldTrialCount(); private: - // Helper function should be called only while holding lock_. - FieldTrial* PreLockedFind(const std::string& name); - // A map from FieldTrial names to the actual instances. typedef std::map<std::string, FieldTrial*> RegistrationList; + // Helper function should be called only while holding lock_. + FieldTrial* PreLockedFind(const std::string& name); + static FieldTrialList* global_; // The singleton of this class. // This will tell us if there is an attempt to register a field trial without diff --git a/base/metrics/histogram.h b/base/metrics/histogram.h index 7ab5a77..3bb3f030 100644 --- a/base/metrics/histogram.h +++ b/base/metrics/histogram.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -542,11 +542,7 @@ class Histogram : public base::RefCountedThreadSafe<Histogram> { // buckets. class LinearHistogram : public Histogram { public: - virtual ClassType histogram_type() const; - - // Store a list of number/text values for use in rendering the histogram. - // The last element in the array has a null in its "description" slot. - virtual void SetRangeDescriptions(const DescriptionPair descriptions[]); + virtual ~LinearHistogram(); /* minimum should start from 1. 0 is as minimum is invalid. 0 is an implicit default underflow bucket. */ @@ -556,7 +552,12 @@ class LinearHistogram : public Histogram { TimeDelta minimum, TimeDelta maximum, size_t bucket_count, Flags flags); - virtual ~LinearHistogram(); + // Overridden from Histogram: + virtual ClassType histogram_type() const; + + // Store a list of number/text values for use in rendering the histogram. + // The last element in the array has a null in its "description" slot. + virtual void SetRangeDescriptions(const DescriptionPair descriptions[]); protected: LinearHistogram(const std::string& name, Sample minimum, @@ -610,11 +611,13 @@ class BooleanHistogram : public LinearHistogram { // CustomHistogram is a histogram for a set of custom integers. class CustomHistogram : public Histogram { public: - virtual ClassType histogram_type() const; static scoped_refptr<Histogram> FactoryGet(const std::string& name, const std::vector<Sample>& custom_ranges, Flags flags); + // Overridden from Histogram: + virtual ClassType histogram_type() const; + protected: CustomHistogram(const std::string& name, const std::vector<Sample>& custom_ranges); diff --git a/base/metrics/stats_table.h b/base/metrics/stats_table.h index 2a4f266..32b22eb 100644 --- a/base/metrics/stats_table.h +++ b/base/metrics/stats_table.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -132,6 +132,7 @@ class StatsTable { private: class Private; struct TLSData; + typedef hash_map<std::string, int> CountersMap; // Returns the space occupied by a thread in the table. Generally used // if a thread terminates but the process continues. This function @@ -171,8 +172,6 @@ class StatsTable { // initialized. TLSData* GetTLSData() const; - typedef hash_map<std::string, int> CountersMap; - Private* impl_; // The counters_lock_ protects the counters_ hash table. diff --git a/base/pickle.h b/base/pickle.h index 6006e62..bbe5d34 100644 --- a/base/pickle.h +++ b/base/pickle.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -32,8 +32,6 @@ // class Pickle { public: - virtual ~Pickle(); - // Initialize a Pickle object using the default header size. Pickle(); @@ -51,6 +49,8 @@ class Pickle { // Initializes a Pickle as a deep copy of another Pickle. Pickle(const Pickle& other); + virtual ~Pickle(); + // Performs a deep copy. Pickle& operator=(const Pickle& other); diff --git a/base/platform_file.cc b/base/platform_file.cc new file mode 100644 index 0000000..70700fc --- /dev/null +++ b/base/platform_file.cc @@ -0,0 +1,17 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/platform_file.h" + +namespace base { + +PlatformFileInfo::PlatformFileInfo() + : size(0), + is_directory(false), + is_symbolic_link(false) { +} + +PlatformFileInfo::~PlatformFileInfo() {} + +} // namespace base diff --git a/base/platform_file.h b/base/platform_file.h index 1ca9868..dd3028b 100644 --- a/base/platform_file.h +++ b/base/platform_file.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -71,6 +71,9 @@ enum PlatformFileError { // too, and the ParamTraits<base::PlatformFileInfo> implementation in // chrome/common/common_param_traits.cc. struct PlatformFileInfo { + PlatformFileInfo(); + ~PlatformFileInfo(); + // The size of the file in bytes. Undefined when is_directory is true. int64 size; diff --git a/base/process_util.h b/base/process_util.h index ce4b0bb..a7f8496 100644 --- a/base/process_util.h +++ b/base/process_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -76,12 +76,6 @@ struct ProcessEntry { ProcessEntry(); ~ProcessEntry(); - ProcessId pid_; - ProcessId ppid_; - ProcessId gid_; - std::string exe_file_; - std::vector<std::string> cmd_line_args_; - ProcessId pid() const { return pid_; } ProcessId parent_pid() const { return ppid_; } ProcessId gid() const { return gid_; } @@ -89,6 +83,12 @@ struct ProcessEntry { const std::vector<std::string>& cmd_line_args() const { return cmd_line_args_; } + + ProcessId pid_; + ProcessId ppid_; + ProcessId gid_; + std::string exe_file_; + std::vector<std::string> cmd_line_args_; }; struct IoCounters { @@ -528,6 +528,8 @@ int64 TimeValToMicroseconds(const struct timeval& tv); // methods. class ProcessMetrics { public: + ~ProcessMetrics(); + // Creates a ProcessMetrics for the specified process. // The caller owns the returned object. #if !defined(OS_MACOSX) @@ -549,8 +551,6 @@ class ProcessMetrics { PortProvider* port_provider); #endif // !defined(OS_MACOSX) - ~ProcessMetrics(); - // Returns the current space allocated for the pagefile, in bytes (these pages // may or may not be in memory). On Linux, this returns the total virtual // memory size. diff --git a/base/ref_counted_memory.h b/base/ref_counted_memory.h index 08400ec..fe7427e 100644 --- a/base/ref_counted_memory.h +++ b/base/ref_counted_memory.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -40,6 +40,7 @@ class RefCountedStaticMemory : public RefCountedMemory { RefCountedStaticMemory(const unsigned char* data, size_t length) : data_(data), length_(length) {} + // Overriden from RefCountedMemory: virtual const unsigned char* front() const; virtual size_t size() const; @@ -54,16 +55,17 @@ class RefCountedStaticMemory : public RefCountedMemory { // vector. class RefCountedBytes : public RefCountedMemory { public: - // Constructs a RefCountedBytes object by performing a swap. (To non - // destructively build a RefCountedBytes, use the constructor that takes a - // vector.) - static RefCountedBytes* TakeVector(std::vector<unsigned char>* to_destroy); - RefCountedBytes(); // Constructs a RefCountedBytes object by _copying_ from |initializer|. RefCountedBytes(const std::vector<unsigned char>& initializer); + // Constructs a RefCountedBytes object by performing a swap. (To non + // destructively build a RefCountedBytes, use the constructor that takes a + // vector.) + static RefCountedBytes* TakeVector(std::vector<unsigned char>* to_destroy); + + // Overriden from RefCountedMemory: virtual const unsigned char* front() const; virtual size_t size() const; diff --git a/base/string_piece.h b/base/string_piece.h index 70c0480..80c6cab 100644 --- a/base/string_piece.h +++ b/base/string_piece.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Copied from strings/stringpiece.h with modifications @@ -29,11 +29,19 @@ namespace base { class StringPiece { public: + // standard STL container boilerplate typedef size_t size_type; + typedef char value_type; + typedef const char* pointer; + typedef const char& reference; + typedef const char& const_reference; + typedef ptrdiff_t difference_type; + typedef const char* const_iterator; + typedef const char* iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; + typedef std::reverse_iterator<iterator> reverse_iterator; - private: - const char* ptr_; - size_type length_; + static const size_type npos; public: // We provide non-explicit singleton constructors so users can pass @@ -113,17 +121,6 @@ class StringPiece { (wordmemcmp(ptr_ + (length_-x.length_), x.ptr_, x.length_) == 0)); } - // standard STL container boilerplate - typedef char value_type; - typedef const char* pointer; - typedef const char& reference; - typedef const char& const_reference; - typedef ptrdiff_t difference_type; - static const size_type npos; - typedef const char* const_iterator; - typedef const char* iterator; - typedef std::reverse_iterator<const_iterator> const_reverse_iterator; - typedef std::reverse_iterator<iterator> reverse_iterator; iterator begin() const { return ptr_; } iterator end() const { return ptr_ + length_; } const_reverse_iterator rbegin() const { @@ -161,6 +158,10 @@ class StringPiece { static int wordmemcmp(const char* p, const char* p2, size_type N) { return memcmp(p, p2, N); } + + private: + const char* ptr_; + size_type length_; }; bool operator==(const StringPiece& x, const StringPiece& y); diff --git a/base/synchronization/waitable_event.h b/base/synchronization/waitable_event.h index 70b9da0..01b5987 100644 --- a/base/synchronization/waitable_event.h +++ b/base/synchronization/waitable_event.h @@ -155,20 +155,21 @@ class WaitableEvent { std::list<Waiter*> waiters_; }; - scoped_refptr<WaitableEventKernel> kernel_; - - bool SignalAll(); - bool SignalOne(); - void Enqueue(Waiter* waiter); + typedef std::pair<WaitableEvent*, size_t> WaiterAndIndex; // When dealing with arrays of WaitableEvent*, we want to sort by the address // of the WaitableEvent in order to have a globally consistent locking order. // In that case we keep them, in sorted order, in an array of pairs where the // second element is the index of the WaitableEvent in the original, // unsorted, array. - typedef std::pair<WaitableEvent*, size_t> WaiterAndIndex; static size_t EnqueueMany(WaiterAndIndex* waitables, size_t count, Waiter* waiter); + + bool SignalAll(); + bool SignalOne(); + void Enqueue(Waiter* waiter); + + scoped_refptr<WaitableEventKernel> kernel_; #endif DISALLOW_COPY_AND_ASSIGN(WaitableEvent); diff --git a/base/synchronization/waitable_event_watcher.h b/base/synchronization/waitable_event_watcher.h index e396368..1b93b66 100644 --- a/base/synchronization/waitable_event_watcher.h +++ b/base/synchronization/waitable_event_watcher.h @@ -115,8 +115,6 @@ class WaitableEventWatcher } private: - WaitableEvent* event_; - #if defined(OS_WIN) // --------------------------------------------------------------------------- // The helper class exists because, if WaitableEventWatcher were to inherit @@ -154,6 +152,8 @@ class WaitableEventWatcher scoped_refptr<WaitableEvent::WaitableEventKernel> kernel_; #endif + WaitableEvent* event_; + Delegate* delegate_; }; diff --git a/base/synchronization/waitable_event_watcher_posix.cc b/base/synchronization/waitable_event_watcher_posix.cc index 048bbd0..0d6ff26 100644 --- a/base/synchronization/waitable_event_watcher_posix.cc +++ b/base/synchronization/waitable_event_watcher_posix.cc @@ -118,11 +118,11 @@ class AsyncCallbackTask : public Task { }; WaitableEventWatcher::WaitableEventWatcher() - : event_(NULL), - message_loop_(NULL), + : message_loop_(NULL), cancel_flag_(NULL), waiter_(NULL), callback_task_(NULL), + event_(NULL), delegate_(NULL) { } diff --git a/base/synchronization/waitable_event_watcher_win.cc b/base/synchronization/waitable_event_watcher_win.cc index 9c02a4c..43e3c47 100644 --- a/base/synchronization/waitable_event_watcher_win.cc +++ b/base/synchronization/waitable_event_watcher_win.cc @@ -21,8 +21,8 @@ void WaitableEventWatcher::ObjectWatcherHelper::OnObjectSignaled(HANDLE h) { WaitableEventWatcher::WaitableEventWatcher() - : event_(NULL), - ALLOW_THIS_IN_INITIALIZER_LIST(helper_(this)), + : ALLOW_THIS_IN_INITIALIZER_LIST(helper_(this)), + event_(NULL), delegate_(NULL) { } diff --git a/base/task_queue.h b/base/task_queue.h index 5bfc777..75b38b2 100644 --- a/base/task_queue.h +++ b/base/task_queue.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -18,10 +18,6 @@ class TaskQueue : public Task { TaskQueue(); ~TaskQueue(); - // Run all the tasks in the queue. New tasks pushed onto the queue during - // a run will be run next time |Run| is called. - virtual void Run(); - // Push the specified task onto the queue. When the queue is run, the tasks // will be run in the order they are pushed. // @@ -35,6 +31,10 @@ class TaskQueue : public Task { // Returns true if this queue contains no tasks. bool IsEmpty() const; + // Run all the tasks in the queue. New tasks pushed onto the queue during + // a run will be run next time |Run| is called. + virtual void Run(); + private: // The list of tasks we are waiting to run. std::deque<Task*> queue_; diff --git a/base/threading/simple_thread.h b/base/threading/simple_thread.h index b107e9c..f55bd62 100644 --- a/base/threading/simple_thread.h +++ b/base/threading/simple_thread.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -82,9 +82,6 @@ class SimpleThread : public PlatformThread::Delegate { virtual void Start(); virtual void Join(); - // We follow the PlatformThread Delegate interface. - virtual void ThreadMain(); - // Subclasses should override the Run method. virtual void Run() = 0; @@ -103,6 +100,9 @@ class SimpleThread : public PlatformThread::Delegate { // Return True if Join() has evern been called. bool HasBeenJoined() { return joined_; } + // Overridden from PlatformThread::Delegate: + virtual void ThreadMain(); + private: const std::string name_prefix_; std::string name_; diff --git a/base/threading/thread.h b/base/threading/thread.h index 17bd33b..811dd80 100644 --- a/base/threading/thread.h +++ b/base/threading/thread.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -29,6 +29,10 @@ namespace base { class Thread : PlatformThread::Delegate { public: struct Options { + Options() : message_loop_type(MessageLoop::TYPE_DEFAULT), stack_size(0) {} + Options(MessageLoop::Type type, size_t size) + : message_loop_type(type), stack_size(size) {} + // Specifies the type of message loop that will be allocated on the thread. MessageLoop::Type message_loop_type; @@ -36,10 +40,6 @@ class Thread : PlatformThread::Delegate { // This does not necessarily correspond to the thread's initial stack size. // A value of 0 indicates that the default maximum should be used. size_t stack_size; - - Options() : message_loop_type(MessageLoop::TYPE_DEFAULT), stack_size(0) {} - Options(MessageLoop::Type type, size_t size) - : message_loop_type(type), stack_size(size) {} }; // Constructor. @@ -152,11 +152,11 @@ class Thread : PlatformThread::Delegate { } private: + bool thread_was_started() const { return started_; } + // PlatformThread::Delegate methods: virtual void ThreadMain(); - bool thread_was_started() const { return started_; } - // Whether we successfully started the thread. bool started_; diff --git a/base/threading/watchdog.h b/base/threading/watchdog.h index bf95639..4af45dc 100644 --- a/base/threading/watchdog.h +++ b/base/threading/watchdog.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -59,9 +59,9 @@ class Watchdog { } virtual void ThreadMain(); private: - Watchdog* watchdog_; - void SetThreadName() const; + + Watchdog* watchdog_; }; enum State {ARMED, DISARMED, SHUTDOWN }; diff --git a/base/time.h b/base/time.h index 79e30b4..e1fbf96 100644 --- a/base/time.h +++ b/base/time.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -385,6 +385,9 @@ class Time { private: friend class TimeDelta; + explicit Time(int64 us) : us_(us) { + } + // Explodes the given time to either local time |is_local = true| or UTC // |is_local = false|. void Explode(bool is_local, Exploded* exploded) const; @@ -393,9 +396,6 @@ class Time { // |is_local = true| or UTC |is_local = false|. static Time FromExploded(bool is_local, const Exploded& exploded); - explicit Time(int64 us) : us_(us) { - } - // The representation of Jan 1, 1970 UTC in microseconds since the // platform-dependent epoch. static const int64 kTimeTToMicrosecondsOffset; diff --git a/base/tracked_objects.h b/base/tracked_objects.h index 3fe2837..07731ff 100644 --- a/base/tracked_objects.h +++ b/base/tracked_objects.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -307,6 +307,8 @@ class DataCollector { void AddListOfLivingObjects(); private: + typedef std::map<const BirthOnThread*, int> BirthCount; + // This instance may be provided to several threads to contribute data. The // following counter tracks how many more threads will contribute. When it is // zero, then all asynchronous contributions are complete, and locked access @@ -318,7 +320,6 @@ class DataCollector { // The total number of births recorded at each location for which we have not // seen a death count. - typedef std::map<const BirthOnThread*, int> BirthCount; BirthCount global_birth_count_; Lock accumulation_lock_; // Protects access during accumulation phase. diff --git a/base/values.h b/base/values.h index 2719d27..d69a685 100644 --- a/base/values.h +++ b/base/values.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -46,6 +46,17 @@ typedef std::map<std::string, Value*> ValueMap; // creating instances of the subclasses. class Value { public: + enum ValueType { + TYPE_NULL = 0, + TYPE_BOOLEAN, + TYPE_INTEGER, + TYPE_REAL, + TYPE_STRING, + TYPE_BINARY, + TYPE_DICTIONARY, + TYPE_LIST + }; + virtual ~Value(); // Convenience methods for creating Value objects for various @@ -62,17 +73,6 @@ class Value { // is non-null, the new object has taken ownership of the buffer pointer. static BinaryValue* CreateBinaryValue(char* buffer, size_t size); - typedef enum { - TYPE_NULL = 0, - TYPE_BOOLEAN, - TYPE_INTEGER, - TYPE_REAL, - TYPE_STRING, - TYPE_BINARY, - TYPE_DICTIONARY, - TYPE_LIST - } ValueType; - // Returns the type of the value stored by the current Value object. // Each type will be implemented by only one subclass of Value, so it's // safe to use the ValueType to determine whether you can cast from @@ -167,6 +167,8 @@ class StringValue : public Value { class BinaryValue: public Value { public: + virtual ~BinaryValue(); + // Creates a Value to represent a binary buffer. The new object takes // ownership of the pointer passed in, if successful. // Returns NULL if buffer is NULL. @@ -178,16 +180,14 @@ class BinaryValue: public Value { // Returns NULL if buffer is NULL. static BinaryValue* CreateWithCopiedBuffer(const char* buffer, size_t size); - virtual ~BinaryValue(); - - // Subclassed methods - virtual Value* DeepCopy() const; - virtual bool Equals(const Value* other) const; - size_t GetSize() const { return size_; } char* GetBuffer() { return buffer_; } const char* GetBuffer() const { return buffer_; } + // Overridden from Value: + virtual Value* DeepCopy() const; + virtual bool Equals(const Value* other) const; + private: // Constructor is private so that only objects with valid buffer pointers // and size values can be created. @@ -207,10 +207,6 @@ class DictionaryValue : public Value { DictionaryValue(); virtual ~DictionaryValue(); - // Subclassed methods - virtual Value* DeepCopy() const; - virtual bool Equals(const Value* other) const; - // Returns true if the current dictionary has a value for the given key. bool HasKey(const std::string& key) const; @@ -333,6 +329,10 @@ class DictionaryValue : public Value { key_iterator begin_keys() const { return key_iterator(dictionary_.begin()); } key_iterator end_keys() const { return key_iterator(dictionary_.end()); } + // Overridden from Value: + virtual Value* DeepCopy() const; + virtual bool Equals(const Value* other) const; + private: ValueMap dictionary_; @@ -342,14 +342,12 @@ class DictionaryValue : public Value { // This type of Value represents a list of other Value values. class ListValue : public Value { public: + typedef ValueVector::iterator iterator; + typedef ValueVector::const_iterator const_iterator; + ListValue(); ~ListValue(); - // Subclassed methods - virtual bool GetAsList(ListValue** out_value); - virtual Value* DeepCopy() const; - virtual bool Equals(const Value* other) const; - // Clears the contents of this ListValue void Clear(); @@ -411,15 +409,17 @@ class ListValue : public Value { } // Iteration - typedef ValueVector::iterator iterator; - typedef ValueVector::const_iterator const_iterator; - ListValue::iterator begin() { return list_.begin(); } ListValue::iterator end() { return list_.end(); } ListValue::const_iterator begin() const { return list_.begin(); } ListValue::const_iterator end() const { return list_.end(); } + // Overridden from Value: + virtual bool GetAsList(ListValue** out_value); + virtual Value* DeepCopy() const; + virtual bool Equals(const Value* other) const; + private: ValueVector list_; diff --git a/base/version.h b/base/version.h index 2fda4ad..28ee227 100644 --- a/base/version.h +++ b/base/version.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,11 +17,6 @@ // Each component is limited to a uint16. class Version { public: - // The version string must be made up of 1 or more uint16's separated - // by '.'. Returns NULL if string is not in this format. - // Caller is responsible for freeing the Version object once done. - static Version* GetVersionFromString(const std::string& version_str); - // Exposed only so that a Version can be stored in STL containers; // any call to the methods below on a default-constructed Version // will DCHECK. @@ -29,6 +24,11 @@ class Version { ~Version(); + // The version string must be made up of 1 or more uint16's separated + // by '.'. Returns NULL if string is not in this format. + // Caller is responsible for freeing the Version object once done. + static Version* GetVersionFromString(const std::string& version_str); + // Creates a copy of this version. Caller takes ownership. Version* Clone() const; diff --git a/gfx/gfx.gyp b/gfx/gfx.gyp index df7d5de..579d3b5 100644 --- a/gfx/gfx.gyp +++ b/gfx/gfx.gyp @@ -1,4 +1,4 @@ -# Copyright (c) 2009 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -32,6 +32,7 @@ 'run_all_unittests.cc', 'scoped_image_unittest.cc', 'skbitmap_operations_unittest.cc', + 'test_suite.cc', 'test_suite.h', '<(SHARED_INTERMEDIATE_DIR)/gfx/gfx_resources.rc', ], diff --git a/gfx/native_theme_linux.h b/gfx/native_theme_linux.h index 62a84e9..4a79da3 100644 --- a/gfx/native_theme_linux.h +++ b/gfx/native_theme_linux.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,9 +19,6 @@ class Size; // Linux theming API. class NativeThemeLinux { public: - // Gets our singleton instance. - static NativeThemeLinux* instance(); - // The part to be painted / sized. enum Part { kScrollbarDownArrow, @@ -54,6 +51,9 @@ class NativeThemeLinux { ScrollbarTrackExtraParams scrollbar_track; }; + // Gets our singleton instance. + static NativeThemeLinux* instance(); + // Return the size of the part. virtual gfx::Size GetSize(Part part) const; // Paint the part to the canvas. diff --git a/gfx/platform_font_gtk.h b/gfx/platform_font_gtk.h index d36142d..a7f3c21 100644 --- a/gfx/platform_font_gtk.h +++ b/gfx/platform_font_gtk.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -27,6 +27,9 @@ class PlatformFontGtk : public PlatformFont { // pango_font_description_free(). static PangoFontDescription* PangoFontFromGfxFont(const gfx::Font& gfx_font); + // Return the scale factor for fonts that account for DPI. + static float GetPangoScaleFactor(); + // Position as an offset from the height of the drawn text, used to draw // an underline. This is a negative number, so the underline would be // drawn at y + height + underline_position; @@ -46,9 +49,6 @@ class PlatformFontGtk : public PlatformFont { virtual int GetFontSize() const; virtual NativeFont GetNativeFont() const; - // Return the scale factor for fonts that account for DPI. - static float GetPangoScaleFactor(); - private: // Create a new instance of this object with the specified properties. Called // from DeriveFont. diff --git a/gfx/test_suite.cc b/gfx/test_suite.cc new file mode 100644 index 0000000..02e1f7f --- /dev/null +++ b/gfx/test_suite.cc @@ -0,0 +1,48 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "gfx/test_suite.h" + +#include "gfx/gfx_paths.h" +#include "base/file_path.h" +#include "base/path_service.h" +#include "base/mac/scoped_nsautorelease_pool.h" + +#if defined(OS_MACOSX) +#include "base/mac/mac_util.h" +#endif + +GfxTestSuite::GfxTestSuite(int argc, char** argv) : TestSuite(argc, argv) {} + +void GfxTestSuite::Initialize() { + base::mac::ScopedNSAutoreleasePool autorelease_pool; + + TestSuite::Initialize(); + + gfx::RegisterPathProvider(); + +#if defined(OS_MACOSX) + // Look in the framework bundle for resources. + // TODO(port): make a resource bundle for non-app exes. What's done here + // isn't really right because this code needs to depend on chrome_dll + // being built. This is inappropriate in app. + FilePath path; + PathService::Get(base::DIR_EXE, &path); +#if defined(GOOGLE_CHROME_BUILD) + path = path.AppendASCII("Google Chrome Framework.framework"); +#elif defined(CHROMIUM_BUILD) + path = path.AppendASCII("Chromium Framework.framework"); +#else +#error Unknown branding +#endif + base::mac::SetOverrideAppBundlePath(path); +#endif // OS_MACOSX +} + +void GfxTestSuite::Shutdown() { +#if defined(OS_MACOSX) + base::mac::SetOverrideAppBundle(NULL); +#endif + TestSuite::Shutdown(); +} diff --git a/gfx/test_suite.h b/gfx/test_suite.h index 8e09e35..7c6ffbd 100644 --- a/gfx/test_suite.h +++ b/gfx/test_suite.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,55 +8,17 @@ #include <string> -#include "gfx/gfx_paths.h" -#include "base/file_path.h" -#include "base/path_service.h" -#include "base/mac/scoped_nsautorelease_pool.h" #include "base/test/test_suite.h" #include "build/build_config.h" -#if defined(OS_MACOSX) -#include "base/mac/mac_util.h" -#endif - class GfxTestSuite : public base::TestSuite { public: - GfxTestSuite(int argc, char** argv) : TestSuite(argc, argv) { - } + GfxTestSuite(int argc, char** argv); protected: - - virtual void Initialize() { - base::mac::ScopedNSAutoreleasePool autorelease_pool; - - TestSuite::Initialize(); - - gfx::RegisterPathProvider(); - -#if defined(OS_MACOSX) - // Look in the framework bundle for resources. - // TODO(port): make a resource bundle for non-app exes. What's done here - // isn't really right because this code needs to depend on chrome_dll - // being built. This is inappropriate in app. - FilePath path; - PathService::Get(base::DIR_EXE, &path); -#if defined(GOOGLE_CHROME_BUILD) - path = path.AppendASCII("Google Chrome Framework.framework"); -#elif defined(CHROMIUM_BUILD) - path = path.AppendASCII("Chromium Framework.framework"); -#else -#error Unknown branding -#endif - base::mac::SetOverrideAppBundlePath(path); -#endif // OS_MACOSX - } - - virtual void Shutdown() { -#if defined(OS_MACOSX) - base::mac::SetOverrideAppBundle(NULL); -#endif - TestSuite::Shutdown(); - } + // Overridden from base::TestSuite: + virtual void Initialize(); + virtual void Shutdown(); }; #endif // GFX_TEST_SUITE_H_ diff --git a/skia/ext/bitmap_platform_device_linux.h b/skia/ext/bitmap_platform_device_linux.h index 27109e3..d183749 100644 --- a/skia/ext/bitmap_platform_device_linux.h +++ b/skia/ext/bitmap_platform_device_linux.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -66,12 +66,6 @@ class BitmapPlatformDevice : public PlatformDevice { class BitmapPlatformDeviceData; public: - static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); - - // This doesn't take ownership of |data| - static BitmapPlatformDevice* Create(int width, int height, - bool is_opaque, uint8_t* data); - // Create a BitmapPlatformDeviceLinux from an already constructed bitmap; // you should probably be using Create(). This may become private later if // we ever have to share state between some native drawing UI and Skia, like @@ -79,27 +73,30 @@ class BitmapPlatformDevice : public PlatformDevice { // // This object takes ownership of @data. BitmapPlatformDevice(const SkBitmap& other, BitmapPlatformDeviceData* data); - virtual ~BitmapPlatformDevice(); - BitmapPlatformDevice& operator=(const BitmapPlatformDevice& other); // A stub copy constructor. Needs to be properly implemented. BitmapPlatformDevice(const BitmapPlatformDevice& other); - virtual SkDeviceFactory* getDeviceFactory(); + virtual ~BitmapPlatformDevice(); - virtual void makeOpaque(int x, int y, int width, int height); + BitmapPlatformDevice& operator=(const BitmapPlatformDevice& other); - // Bitmaps aren't vector graphics. - virtual bool IsVectorial(); + static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); - // If someone wants to paint on a Cairo surface version of our - // buffer, then give them the surface we're already using. - virtual cairo_t* beginPlatformPaint(); + // This doesn't take ownership of |data| + static BitmapPlatformDevice* Create(int width, int height, + bool is_opaque, uint8_t* data); - // Loads the given transform and clipping region into the HDC. This is - // overridden from SkDevice. + virtual void makeOpaque(int x, int y, int width, int height); + + // Overridden from SkDevice: + virtual SkDeviceFactory* getDeviceFactory(); virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region); + // Overridden from PlatformDevice: + virtual bool IsVectorial(); + virtual cairo_t* beginPlatformPaint(); + private: static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, cairo_surface_t* surface); diff --git a/skia/ext/convolver.h b/skia/ext/convolver.h index 97f191c..80c48a9 100644 --- a/skia/ext/convolver.h +++ b/skia/ext/convolver.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -25,11 +25,11 @@ namespace skia { // Entries are stored in fixed point, shifted left by kShiftBits. class ConvolutionFilter1D { public: + typedef short Fixed; + // The number of bits that fixed point values are shifted by. enum { kShiftBits = 14 }; - typedef short Fixed; - ConvolutionFilter1D(); ~ConvolutionFilter1D(); diff --git a/skia/ext/platform_canvas.h b/skia/ext/platform_canvas.h index 1e51717..fd65fc0 100644 --- a/skia/ext/platform_canvas.h +++ b/skia/ext/platform_canvas.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -24,32 +24,15 @@ class PlatformCanvas : public SkCanvas { // Set is_opaque if you are going to erase the bitmap and not use // transparency: this will enable some optimizations. PlatformCanvas(int width, int height, bool is_opaque); - virtual ~PlatformCanvas(); #if defined(WIN32) - // Windows ------------------------------------------------------------------ - // The shared_section parameter is passed to gfx::PlatformDevice::create. // See it for details. PlatformCanvas(int width, int height, bool is_opaque, HANDLE shared_section); - - // For two-part init, call if you use the no-argument constructor above. Note - // that we want this to optionally match the Linux initialize if you only - // pass 3 arguments, hence the evil default argument. - bool initialize(int width, int height, bool is_opaque, - HANDLE shared_section = NULL); - #elif defined(__APPLE__) - // Mac ----------------------------------------------------------------------- - PlatformCanvas(int width, int height, bool is_opaque, CGContextRef context); PlatformCanvas(int width, int height, bool is_opaque, uint8_t* context); - - // For two-part init, call if you use the no-argument constructor above - bool initialize(CGContextRef context, int width, int height, bool is_opaque); - bool initialize(int width, int height, bool is_opaque, uint8_t* data = NULL); - #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \ defined(__Solaris__) // Linux --------------------------------------------------------------------- @@ -57,11 +40,27 @@ class PlatformCanvas : public SkCanvas { // Construct a canvas from the given memory region. The memory is not cleared // first. @data must be, at least, @height * StrideForWidth(@width) bytes. PlatformCanvas(int width, int height, bool is_opaque, uint8_t* data); +#endif + + virtual ~PlatformCanvas(); +#if defined(WIN32) + // For two-part init, call if you use the no-argument constructor above. Note + // that we want this to optionally match the Linux initialize if you only + // pass 3 arguments, hence the evil default argument. + bool initialize(int width, int height, bool is_opaque, + HANDLE shared_section = NULL); +#elif defined(__APPLE__) // For two-part init, call if you use the no-argument constructor above + bool initialize(CGContextRef context, int width, int height, bool is_opaque); bool initialize(int width, int height, bool is_opaque, uint8_t* data = NULL); +#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \ + defined(__Solaris__) + // For two-part init, call if you use the no-argument constructor above + bool initialize(int width, int height, bool is_opaque, uint8_t* data = NULL); #endif + // Shared -------------------------------------------------------------------- // These calls should surround calls to platform drawing routines, the @@ -99,6 +98,9 @@ class PlatformCanvas : public SkCanvas { using SkCanvas::clipRect; private: + // Helper method used internally by the initialize() methods. + bool initializeWithDevice(SkDevice* device); + // Unimplemented. This is to try to prevent people from calling this function // on SkCanvas. SkCanvas' version is not virtual, so we can't prevent this // 100%, but hopefully this will make people notice and not use the function. @@ -107,9 +109,6 @@ class PlatformCanvas : public SkCanvas { // CoreGraphics. virtual SkDevice* setBitmapDevice(const SkBitmap& bitmap); - // Helper method used internally by the initialize() methods. - bool initializeWithDevice(SkDevice* device); - // Disallow copy and assign. PlatformCanvas(const PlatformCanvas&); PlatformCanvas& operator=(const PlatformCanvas&); diff --git a/skia/ext/vector_platform_device_linux.h b/skia/ext/vector_platform_device_linux.h index 1cf8a0c..eb767cc 100644 --- a/skia/ext/vector_platform_device_linux.h +++ b/skia/ext/vector_platform_device_linux.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,11 +14,12 @@ namespace skia { class VectorPlatformDeviceFactory : public SkDeviceFactory { public: - virtual SkDevice* newDevice(SkBitmap::Config config, int width, int height, - bool isOpaque, bool isForLayer); - static SkDevice* CreateDevice(cairo_t* context, int width, int height, bool isOpaque); + + // Overridden from SkDeviceFactory: + virtual SkDevice* newDevice(SkBitmap::Config config, int width, int height, + bool isOpaque, bool isForLayer); }; // This device is basically a wrapper that provides a surface for SkCanvas @@ -28,17 +29,23 @@ class VectorPlatformDeviceFactory : public SkDeviceFactory { // meaningless. class VectorPlatformDevice : public PlatformDevice { public: + virtual ~VectorPlatformDevice(); + // Factory function. Ownership of |context| is not transferred. static VectorPlatformDevice* create(PlatformSurface context, int width, int height); - virtual ~VectorPlatformDevice(); + // Clean up cached fonts. It is an error to call this while some + // VectorPlatformDevice callee is still using fonts created for it by this + // class. + static void ClearFontCache(); + + // Overridden from SkDevice (through PlatformDevice): virtual SkDeviceFactory* getDeviceFactory(); + // Overridden from PlatformDevice: virtual bool IsVectorial(); virtual PlatformSurface beginPlatformPaint(); - - // We translate following skia APIs into corresponding Cairo APIs. virtual void drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, const SkMatrix& matrix, const SkPaint& paint); virtual void drawDevice(const SkDraw& draw, SkDevice*, int x, int y, @@ -69,11 +76,6 @@ class VectorPlatformDevice : public PlatformDevice { virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region); - // Clean up cached fonts. It is an error to call this while some - // VectorPlatformDevice callee is still using fonts created for it by this - // class. - static void ClearFontCache(); - protected: explicit VectorPlatformDevice(PlatformSurface context, const SkBitmap& bitmap); diff --git a/webkit/plugins/npapi/plugin_host.cc b/webkit/plugins/npapi/plugin_host.cc index 1fd542f..52c2a96 100644 --- a/webkit/plugins/npapi/plugin_host.cc +++ b/webkit/plugins/npapi/plugin_host.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -460,7 +460,7 @@ static NPError PostURLNotify(NPP id, base::SysNativeMBToWide(file_path_ascii)); } - base::PlatformFileInfo post_file_info = {0}; + base::PlatformFileInfo post_file_info; if (!file_util::GetFileInfo(file_path, &post_file_info) || post_file_info.is_directory) return NPERR_FILE_NOT_FOUND; |