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

Unified Diff: mojo/public/bindings/lib/shared_data.h

Issue 198343002: Mojo: request/response bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 months 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
« no previous file with comments | « mojo/public/bindings/lib/router.cc ('k') | mojo/public/bindings/lib/shared_ptr.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/bindings/lib/shared_data.h
diff --git a/mojo/public/bindings/lib/shared_data.h b/mojo/public/bindings/lib/shared_data.h
index 791c54e9c574d23635314a2b5f0f693bfd7721dd..c40b8f91330520692251a003b29022a2a66a12c8 100644
--- a/mojo/public/bindings/lib/shared_data.h
+++ b/mojo/public/bindings/lib/shared_data.h
@@ -16,6 +16,9 @@ class SharedData {
holder_->Release();
}
+ SharedData() : holder_(new Holder()) {
+ }
+
explicit SharedData(const T& value) : holder_(new Holder(value)) {
}
@@ -31,16 +34,27 @@ class SharedData {
holder_->Retain();
}
+ 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:
- SharedData(); // NOT IMPLEMENTED
-
class Holder {
public:
Holder() : value(), ref_count_(1) {
« no previous file with comments | « mojo/public/bindings/lib/router.cc ('k') | mojo/public/bindings/lib/shared_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698