Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1533)

Unified Diff: third_party/mojo/src/mojo/public/cpp/bindings/lib/shared_data.h

Issue 1410053006: Move third_party/mojo/src/mojo/public to mojo/public (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/mojo/src/mojo/public/cpp/bindings/lib/shared_data.h
diff --git a/third_party/mojo/src/mojo/public/cpp/bindings/lib/shared_data.h b/third_party/mojo/src/mojo/public/cpp/bindings/lib/shared_data.h
deleted file mode 100644
index 1490fc55917e6debf69b99d2fd902de6a7b44f2a..0000000000000000000000000000000000000000
--- a/third_party/mojo/src/mojo/public/cpp/bindings/lib/shared_data.h
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright 2014 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.
-
-#ifndef THIRD_PARTY_MOJO_SRC_MOJO_PUBLIC_CPP_BINDINGS_LIB_SHARED_DATA_H_
-#define THIRD_PARTY_MOJO_SRC_MOJO_PUBLIC_CPP_BINDINGS_LIB_SHARED_DATA_H_
-
-#include <assert.h>
-
-#include "third_party/mojo/src/mojo/public/cpp/bindings/lib/thread_checker.h"
-#include "third_party/mojo/src/mojo/public/cpp/system/macros.h"
-
-namespace mojo {
-namespace internal {
-
-// Used to allocate an instance of T that can be shared via reference counting.
-template <typename T>
-class SharedData {
- public:
- ~SharedData() { holder_->Release(); }
-
- SharedData() : holder_(new Holder()) {}
-
- explicit SharedData(const T& value) : holder_(new Holder(value)) {}
-
- SharedData(const SharedData<T>& other) : holder_(other.holder_) {
- holder_->Retain();
- }
-
- SharedData<T>& operator=(const SharedData<T>& other) {
- if (other.holder_ == holder_)
- return *this;
- holder_->Release();
- holder_ = other.holder_;
- holder_->Retain();
- return *this;
- }
-
- void reset() {
- holder_->Release();
- holder_ = new Holder();
- }
-
- void reset(const T& value) {
- holder_->Release();
- holder_ = new Holder(value);
- }
-
- void set_value(const T& value) { holder_->value = value; }
- T* mutable_value() { return &holder_->value; }
- const T& value() const { return holder_->value; }
-
- private:
- class Holder {
- public:
- Holder() : value(), ref_count_(1) {}
- Holder(const T& value) : value(value), ref_count_(1) {}
-
- void Retain() {
- assert(thread_checker_.CalledOnValidThread());
- ++ref_count_;
- }
- void Release() {
- assert(thread_checker_.CalledOnValidThread());
- if (--ref_count_ == 0)
- delete this;
- }
-
- T value;
-
- private:
- int ref_count_;
- ThreadChecker thread_checker_;
- MOJO_DISALLOW_COPY_AND_ASSIGN(Holder);
- };
-
- Holder* holder_;
-};
-
-} // namespace internal
-} // namespace mojo
-
-#endif // THIRD_PARTY_MOJO_SRC_MOJO_PUBLIC_CPP_BINDINGS_LIB_SHARED_DATA_H_

Powered by Google App Engine
This is Rietveld 408576698