FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GitHub Viewer

// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 // Google Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the name Chromium Embedded // Framework nor the names of its contributors may be used to endorse // or promote products derived from this software without specific prior // written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_H_ #define CEF_INCLUDE_BASE_CEF_CALLBACK_H_ #pragma once #if defined(BASE_CALLBACK_H_) // Do nothing if the Chromium header has already been included. // This can happen in cases where Chromium code is used directly by the // client application. When using Chromium code directly always include // the Chromium header first to avoid type conflicts. #elif defined(USING_CHROMIUM_INCLUDES) // When building CEF include the Chromium header directly. #include "base/callback.h" #else // !USING_CHROMIUM_INCLUDES // The following is substantially similar to the Chromium implementation. // If the Chromium implementation diverges the below implementation should be // updated to match. #include "include/base/internal/cef_callback_internal.h" #include "include/base/cef_callback_forward.h" #include "include/base/cef_template_util.h" // NOTE: Header files that do not require the full definition of Callback or // Closure should #include "base/cef_callback_forward.h" instead of this file. // ----------------------------------------------------------------------------- // Introduction // ----------------------------------------------------------------------------- // // The templated Callback class is a generalized function object. Together // with the Bind() function in bind.h, they provide a type-safe method for // performing partial application of functions. // // Partial application (or "currying") is the process of binding a subset of // a function's arguments to produce another function that takes fewer // arguments. This can be used to pass around a unit of delayed execution, // much like lexical closures are used in other languages. For example, it // is used in Chromium code to schedule tasks on different MessageLoops. // // A callback with no unbound input parameters (base::Callback) // is called a base::Closure. Note that this is NOT the same as what other // languages refer to as a closure -- it does not retain a reference to its // enclosing environment. // // MEMORY MANAGEMENT AND PASSING // // The Callback objects themselves should be passed by const-reference, and // stored by copy. They internally store their state via a refcounted class // and thus do not need to be deleted. // // The reason to pass via a const-reference is to avoid unnecessary // AddRef/Release pairs to the internal state. // // // ----------------------------------------------------------------------------- // Quick reference for basic stuff // ----------------------------------------------------------------------------- // // BINDING A BARE FUNCTION // // int Return5() { return 5; } // base::Callback func_cb = base::Bind(&Return5); // LOG(INFO)

Back | FazBrowse Home | New Git URL