Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/android/blimp/blimp_contents_profile_attachment.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/supports_user_data.h" | |
| 9 #include "blimp/client/public/blimp_contents.h" | |
| 10 | |
| 11 namespace { | |
| 12 const char kBlimpContentsProfileAttachment[] = | |
| 13 "blimp_contents_profile_attachment"; | |
| 14 | |
| 15 // A holder struct for a Profile that can be used as data. | |
| 16 struct Attachment : public base::SupportsUserData::Data { | |
| 17 public: | |
|
Lei Zhang
2016/07/14 23:21:57
Aren't struct members public by default?
nyquist
2016/07/15 17:38:19
Done.
| |
| 18 Profile* profile; | |
| 19 }; | |
| 20 | |
| 21 } // namespace | |
| 22 | |
| 23 namespace chrome { | |
| 24 | |
| 25 void AttachProfileToBlimpContents(blimp::client::BlimpContents* blimp_contents, | |
| 26 Profile* profile) { | |
| 27 DCHECK(profile); | |
| 28 Attachment* attachment = new Attachment; | |
| 29 attachment->profile = profile; | |
| 30 blimp_contents->SetUserData(kBlimpContentsProfileAttachment, attachment); | |
| 31 } | |
| 32 | |
| 33 Profile* GetProfileFromBlimpContents( | |
| 34 blimp::client::BlimpContents* blimp_contents) { | |
| 35 Attachment* attachment = static_cast<Attachment*>( | |
| 36 blimp_contents->GetUserData(kBlimpContentsProfileAttachment)); | |
| 37 DCHECK(attachment); | |
| 38 return attachment->profile; | |
| 39 } | |
| 40 | |
| 41 } // namespace chrome | |
| OLD | NEW |