Wednesday, January 30, 2013

Chromium, Trace ApiFunction

1) RefCountedThreadSafeBase
- BASE_EXPORT

#RefCountedThreadSafe class와 그냥 RefCountedBase가 있다.

일반적으로 AddRef를 하면 +1 Relase를 하면 -1을 하여 Reference Cnt를센다

ThreadSafe class는 어셈블리레벨에서 lock을 걸어 thread에 안전하도록한다.

AddRef에서 count를 더하고 Release에서 count를 뺀다

public subtle::RefCountedThreadSafeBase (src/base/memory/ref_counted.h)

 class BASE_EXPORT RefCountedThreadSafeBase {
 public:
  bool HasOneRef() const;

 protected:
  RefCountedThreadSafeBase();
  ~RefCountedThreadSafeBase();

  void AddRef() const;

  // Returns true if the object should self-delete.
  bool Release() const;

 private:
  mutable AtomicRefCount ref_count_;
#ifndef NDEBUG
  mutable bool in_dtor_;
#endif

  DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafeBase);
};

}  // namespace subtle

//
// A base class for reference counted classes.  Otherwise, known as a cheap


2. RefCountedThreadSafe


RefCountedThreadSafe (base\memory\ref_counted.h)->


template <class T, typename Traits = DefaultRefCountedThreadSafeTraits<T> >
class RefCountedThreadSafe : public subtle::RefCountedThreadSafeBase {

AddRef()는 RefCountedThreadSafeBase::AddRef()만을 호출하지만
Release()는 RefCountedThreadSafeBase::Rlease()를 호출하고 Traits::Desctructor(*this)를 호출한다.

trait class를 사용한다.
template class 를 작성하는 사람이라면,
template 으로 사용하고 있는 T 가 특정 함수를 가지고 있는지 compile time 에 확인(assure) 할 수 있으면 하는 때가 있었을 것이다.

traits class 는 template class 등에서
class T의 특정 속성(function, variable)이 있음을 assure하기 위한 클래스라 보면 될 것이다.
http://accu.org/index.php/journals/442

3. ExtensionFunction


ExtensionFunction (chrome\browser\extension\extension_function.h) ->
// Abstract base class for extension functions the ExtensionFunctionDispatcher
// knows how to dispatch to.

class ExtensionFunction
    : public base::RefCountedThreadSafe<ExtensionFunction,
                                        ExtensionFunctionDeleteTraits> {

애부터가 진짜 Extension을 위한 함수이다.
볼게 너무 많다


4. UIThreadExtensionFunction 

// Extension functions that run on the UI thread. Most functions fall into
// this category.
class UIThreadExtensionFunction : public ExtensionFunction {

5. ApiFunction

class ApiFunction : public UIThreadExtensionFunction {
별거없다 이름만 바꾼것같음
ApiFunction을 바로 상속하는놈이 있으면 없애도 되지않을까?

6. AsyncApiFunction


// AsyncApiFunction provides convenient thread management for APIs that need to
// do essentially all their work on a thread other than the UI thread.

class AsyncApiFunction : public ApiFunction {


7. SerialAsyncApiFunction

class SerialAsyncApiFunction : public AsyncApiFunction {


8. SerialOpenFunction

 class SerialOpenFunction : public SerialAsyncApiFunction {



-----------------------------------------------------------

extension API ->

AsyncAPIFunction ->

ApiFunction ->

UIThreadExtensionFunction  ->

ExtensionFunction (chrome\browser\extension\extension_function.h) ->
// Abstract base class for extension functions the ExtensionFunctionDispatcher
// knows how to dispatch to.

public base::RefCountedThreadSafe<ExtensionFunction, ExtensionFunctionDeleteTraits> ->

RefCountedThreadSafe (base\memory\ref_counted.h)->

trait class를 사용한다.
template class 를 작성하는 사람이라면,
template 으로 사용하고 있는 T 가 특정 함수를 가지고 있는지 compile time 에 확인(assure) 할 수 있으면 하는 때가 있었을 것이다.

traits class 는 template class 등에서
class T의 특정 속성(function, variable)이 있음을 assure하기 위한 클래스라 보면 될 것이다.
http://accu.org/index.php/journals/442

RefCountedThreadSafeBase

#ThreadSafe class와 그냥 RefCountedBase가 있다.

일반적으로 AddRef를 하면 +1 Relase를 하면 -1을 하여 Reference Cnt를센다

ThreadSafe class는 어셈블리레벨에서 lock을 걸어 thread에 안전하도록한다.

public subtle::RefCountedThreadSafeBase (src/base/memory/ref_counted.h)

 class BASE_EXPORT RefCountedThreadSafeBase {
 public:
  bool HasOneRef() const;

 protected:
  RefCountedThreadSafeBase();
  ~RefCountedThreadSafeBase();

  void AddRef() const;

  // Returns true if the object should self-delete.
  bool Release() const;

 private:
  mutable AtomicRefCount ref_count_;
#ifndef NDEBUG
  mutable bool in_dtor_;
#endif

  DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafeBase);
};

}  // namespace subtle

//
// A base class for reference counted classes.  Otherwise, known as a cheap

No comments:

Post a Comment