summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-02 17:59:13 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-02 17:59:13 +0000
commit33ae34cd0174a199b85c6dc22145c72e007a1ee8 (patch)
tree28ad112df8cee7b3a25bfaff370ee09b6cb32a00 /ppapi/cpp
parent37f4a67b9b5f017b24ccec263c384d7ff1e1a387 (diff)
downloadchromium_src-33ae34cd0174a199b85c6dc22145c72e007a1ee8.zip
chromium_src-33ae34cd0174a199b85c6dc22145c72e007a1ee8.tar.gz
chromium_src-33ae34cd0174a199b85c6dc22145c72e007a1ee8.tar.bz2
Remove all the swap() stuff in the PPAPI C++ wrappers.
Basically all of them are trivial and you can use the std::swap just as efficiently. Since this is unnecessary, we can reduce the complexity a bit. TEST=none BUG=54441 Review URL: http://codereview.chromium.org/5539001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68028 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp')
-rw-r--r--ppapi/cpp/dev/buffer_dev.cc11
-rw-r--r--ppapi/cpp/dev/buffer_dev.h1
-rw-r--r--ppapi/cpp/dev/directory_entry_dev.cc12
-rw-r--r--ppapi/cpp/dev/directory_entry_dev.h1
-rw-r--r--ppapi/cpp/dev/directory_reader_dev.cc7
-rw-r--r--ppapi/cpp/dev/directory_reader_dev.h1
-rw-r--r--ppapi/cpp/dev/file_chooser_dev.cc6
-rw-r--r--ppapi/cpp/dev/file_chooser_dev.h1
-rw-r--r--ppapi/cpp/dev/file_io_dev.cc7
-rw-r--r--ppapi/cpp/dev/file_io_dev.h1
-rw-r--r--ppapi/cpp/dev/file_ref_dev.cc7
-rw-r--r--ppapi/cpp/dev/file_ref_dev.h1
-rw-r--r--ppapi/cpp/dev/font_dev.cc48
-rw-r--r--ppapi/cpp/dev/font_dev.h7
-rw-r--r--ppapi/cpp/dev/scrollbar_dev.cc7
-rw-r--r--ppapi/cpp/dev/scrollbar_dev.h1
-rw-r--r--ppapi/cpp/dev/video_decoder_dev.cc7
-rw-r--r--ppapi/cpp/dev/video_decoder_dev.h1
-rw-r--r--ppapi/cpp/dev/widget_dev.cc7
-rw-r--r--ppapi/cpp/dev/widget_dev.h1
20 files changed, 26 insertions, 109 deletions
diff --git a/ppapi/cpp/dev/buffer_dev.cc b/ppapi/cpp/dev/buffer_dev.cc
index 839ab8d..3f5c2c8 100644
--- a/ppapi/cpp/dev/buffer_dev.cc
+++ b/ppapi/cpp/dev/buffer_dev.cc
@@ -40,16 +40,11 @@ Buffer_Dev::~Buffer_Dev() {
}
Buffer_Dev& Buffer_Dev::operator=(const Buffer_Dev& other) {
- Buffer_Dev copy(other);
- swap(copy);
+ Resource::operator=(other);
+ size_ = other.size_;
+ data_ = other.data_;
return *this;
}
-void Buffer_Dev::swap(Buffer_Dev& other) {
- Resource::swap(other);
- std::swap(size_, other.size_);
- std::swap(data_, other.data_);
-}
-
} // namespace pp
diff --git a/ppapi/cpp/dev/buffer_dev.h b/ppapi/cpp/dev/buffer_dev.h
index 8459147..19e9e68 100644
--- a/ppapi/cpp/dev/buffer_dev.h
+++ b/ppapi/cpp/dev/buffer_dev.h
@@ -23,7 +23,6 @@ class Buffer_Dev : public Resource {
~Buffer_Dev();
Buffer_Dev& operator=(const Buffer_Dev& other);
- void swap(Buffer_Dev& other);
uint32_t size() const { return size_; }
void* data() const { return data_; }
diff --git a/ppapi/cpp/dev/directory_entry_dev.cc b/ppapi/cpp/dev/directory_entry_dev.cc
index a5f8179..80de22f 100644
--- a/ppapi/cpp/dev/directory_entry_dev.cc
+++ b/ppapi/cpp/dev/directory_entry_dev.cc
@@ -28,14 +28,12 @@ DirectoryEntry_Dev::~DirectoryEntry_Dev() {
DirectoryEntry_Dev& DirectoryEntry_Dev::operator=(
const DirectoryEntry_Dev& other) {
- DirectoryEntry_Dev copy(other);
- swap(copy);
+ if (data_.file_ref)
+ Module::Get()->core()->ReleaseResource(data_.file_ref);
+ data_ = other.data_;
+ if (data_.file_ref)
+ Module::Get()->core()->AddRefResource(data_.file_ref);
return *this;
}
-void DirectoryEntry_Dev::swap(DirectoryEntry_Dev& other) {
- std::swap(data_.file_ref, other.data_.file_ref);
- std::swap(data_.file_type, other.data_.file_type);
-}
-
} // namespace pp
diff --git a/ppapi/cpp/dev/directory_entry_dev.h b/ppapi/cpp/dev/directory_entry_dev.h
index 84ef623..0e902f7 100644
--- a/ppapi/cpp/dev/directory_entry_dev.h
+++ b/ppapi/cpp/dev/directory_entry_dev.h
@@ -17,7 +17,6 @@ class DirectoryEntry_Dev {
~DirectoryEntry_Dev();
DirectoryEntry_Dev& operator=(const DirectoryEntry_Dev& other);
- void swap(DirectoryEntry_Dev& other);
// Returns true if the DirectoryEntry is invalid or uninitialized.
bool is_null() const { return !data_.file_ref; }
diff --git a/ppapi/cpp/dev/directory_reader_dev.cc b/ppapi/cpp/dev/directory_reader_dev.cc
index bcf5e11..0802944 100644
--- a/ppapi/cpp/dev/directory_reader_dev.cc
+++ b/ppapi/cpp/dev/directory_reader_dev.cc
@@ -33,15 +33,10 @@ DirectoryReader_Dev::DirectoryReader_Dev(const DirectoryReader_Dev& other)
DirectoryReader_Dev& DirectoryReader_Dev::operator=(
const DirectoryReader_Dev& other) {
- DirectoryReader_Dev copy(other);
- swap(copy);
+ Resource::operator=(other);
return *this;
}
-void DirectoryReader_Dev::swap(DirectoryReader_Dev& other) {
- Resource::swap(other);
-}
-
int32_t DirectoryReader_Dev::GetNextEntry(DirectoryEntry_Dev* entry,
const CompletionCallback& cc) {
if (!directory_reader_f)
diff --git a/ppapi/cpp/dev/directory_reader_dev.h b/ppapi/cpp/dev/directory_reader_dev.h
index e90fbc0..92f2a23 100644
--- a/ppapi/cpp/dev/directory_reader_dev.h
+++ b/ppapi/cpp/dev/directory_reader_dev.h
@@ -24,7 +24,6 @@ class DirectoryReader_Dev : public Resource {
DirectoryReader_Dev(const DirectoryReader_Dev& other);
DirectoryReader_Dev& operator=(const DirectoryReader_Dev& other);
- void swap(DirectoryReader_Dev& other);
// See PPB_DirectoryReader::GetNextEntry.
int32_t GetNextEntry(DirectoryEntry_Dev* entry,
diff --git a/ppapi/cpp/dev/file_chooser_dev.cc b/ppapi/cpp/dev/file_chooser_dev.cc
index 051ab38..458ba12 100644
--- a/ppapi/cpp/dev/file_chooser_dev.cc
+++ b/ppapi/cpp/dev/file_chooser_dev.cc
@@ -33,14 +33,10 @@ FileChooser_Dev::FileChooser_Dev(const FileChooser_Dev& other)
}
FileChooser_Dev& FileChooser_Dev::operator=(const FileChooser_Dev& other) {
- FileChooser_Dev copy(other);
- swap(copy);
+ Resource::operator=(other);
return *this;
}
-void FileChooser_Dev::swap(FileChooser_Dev& other) {
- Resource::swap(other);
-}
int32_t FileChooser_Dev::Show(const CompletionCallback& cc) {
if (!file_chooser_f)
diff --git a/ppapi/cpp/dev/file_chooser_dev.h b/ppapi/cpp/dev/file_chooser_dev.h
index f611b1e..2d0ed22 100644
--- a/ppapi/cpp/dev/file_chooser_dev.h
+++ b/ppapi/cpp/dev/file_chooser_dev.h
@@ -26,7 +26,6 @@ class FileChooser_Dev : public Resource {
FileChooser_Dev(const FileChooser_Dev& other);
FileChooser_Dev& operator=(const FileChooser_Dev& other);
- void swap(FileChooser_Dev& other);
// PPB_FileChooser methods:
int32_t Show(const CompletionCallback& cc);
diff --git a/ppapi/cpp/dev/file_io_dev.cc b/ppapi/cpp/dev/file_io_dev.cc
index 54731ed..e1197a1 100644
--- a/ppapi/cpp/dev/file_io_dev.cc
+++ b/ppapi/cpp/dev/file_io_dev.cc
@@ -34,15 +34,10 @@ FileIO_Dev::FileIO_Dev(const FileIO_Dev& other)
}
FileIO_Dev& FileIO_Dev::operator=(const FileIO_Dev& other) {
- FileIO_Dev copy(other);
- swap(copy);
+ Resource::operator=(other);
return *this;
}
-void FileIO_Dev::swap(FileIO_Dev& other) {
- Resource::swap(other);
-}
-
int32_t FileIO_Dev::Open(const FileRef_Dev& file_ref,
int32_t open_flags,
const CompletionCallback& cc) {
diff --git a/ppapi/cpp/dev/file_io_dev.h b/ppapi/cpp/dev/file_io_dev.h
index e38c2e1..957f9eb 100644
--- a/ppapi/cpp/dev/file_io_dev.h
+++ b/ppapi/cpp/dev/file_io_dev.h
@@ -21,7 +21,6 @@ class FileIO_Dev : public Resource {
FileIO_Dev(const FileIO_Dev& other);
FileIO_Dev& operator=(const FileIO_Dev& other);
- void swap(FileIO_Dev& other);
// PPB_FileIO methods:
int32_t Open(const FileRef_Dev& file_ref,
diff --git a/ppapi/cpp/dev/file_ref_dev.cc b/ppapi/cpp/dev/file_ref_dev.cc
index d5c5ec0..9a8db58 100644
--- a/ppapi/cpp/dev/file_ref_dev.cc
+++ b/ppapi/cpp/dev/file_ref_dev.cc
@@ -36,15 +36,10 @@ FileRef_Dev::FileRef_Dev(const FileRef_Dev& other)
}
FileRef_Dev& FileRef_Dev::operator=(const FileRef_Dev& other) {
- FileRef_Dev copy(other);
- swap(copy);
+ Resource::operator=(other);
return *this;
}
-void FileRef_Dev::swap(FileRef_Dev& other) {
- Resource::swap(other);
-}
-
PP_FileSystemType_Dev FileRef_Dev::GetFileSystemType() const {
if (!file_ref_f)
return PP_FILESYSTEMTYPE_EXTERNAL;
diff --git a/ppapi/cpp/dev/file_ref_dev.h b/ppapi/cpp/dev/file_ref_dev.h
index b2d10a6..99abd03 100644
--- a/ppapi/cpp/dev/file_ref_dev.h
+++ b/ppapi/cpp/dev/file_ref_dev.h
@@ -35,7 +35,6 @@ class FileRef_Dev : public Resource {
FileRef_Dev(const FileRef_Dev& other);
FileRef_Dev& operator=(const FileRef_Dev& other);
- void swap(FileRef_Dev& other);
// Returns the file system type.
PP_FileSystemType_Dev GetFileSystemType() const;
diff --git a/ppapi/cpp/dev/font_dev.cc b/ppapi/cpp/dev/font_dev.cc
index 185c63f..a58aec2 100644
--- a/ppapi/cpp/dev/font_dev.cc
+++ b/ppapi/cpp/dev/font_dev.cc
@@ -50,28 +50,14 @@ FontDescription_Dev::~FontDescription_Dev() {
FontDescription_Dev& FontDescription_Dev::operator=(
const FontDescription_Dev& other) {
- FontDescription_Dev copy(other);
- swap(copy);
- return *this;
-}
+ pp_font_description_ = other.pp_font_description_;
-void FontDescription_Dev::swap(FontDescription_Dev& other) {
- // Need to fix up both the face and the pp_font_description_.face which the
- // setter does for us.
- Var temp = face();
+ // Be careful about the refcount of the string, the copy that operator= made
+ // above didn't copy a ref.
+ pp_font_description_.face = PP_MakeUndefined();
set_face(other.face());
- other.set_face(temp);
- std::swap(pp_font_description_.family, other.pp_font_description_.family);
- std::swap(pp_font_description_.size, other.pp_font_description_.size);
- std::swap(pp_font_description_.weight, other.pp_font_description_.weight);
- std::swap(pp_font_description_.italic, other.pp_font_description_.italic);
- std::swap(pp_font_description_.small_caps,
- other.pp_font_description_.small_caps);
- std::swap(pp_font_description_.letter_spacing,
- other.pp_font_description_.letter_spacing);
- std::swap(pp_font_description_.word_spacing,
- other.pp_font_description_.word_spacing);
+ return *this;
}
// TextRun_Dev -----------------------------------------------------------------
@@ -101,21 +87,10 @@ TextRun_Dev::~TextRun_Dev() {
}
TextRun_Dev& TextRun_Dev::operator=(const TextRun_Dev& other) {
- TextRun_Dev copy(other);
- swap(copy);
- return *this;
-}
-
-void TextRun_Dev::swap(TextRun_Dev& other) {
- std::swap(text_, other.text_);
-
- // Fix up both object's pp_text_run.text to point to their text_ member.
+ pp_text_run_ = other.pp_text_run_;
+ text_ = other.text_;
pp_text_run_.text = text_.pp_var();
- other.pp_text_run_.text = other.text_.pp_var();
-
- std::swap(pp_text_run_.rtl, other.pp_text_run_.rtl);
- std::swap(pp_text_run_.override_direction,
- other.pp_text_run_.override_direction);
+ return *this;
}
// Font ------------------------------------------------------------------------
@@ -134,15 +109,10 @@ Font_Dev::Font_Dev(const Font_Dev& other) : Resource(other) {
}
Font_Dev& Font_Dev::operator=(const Font_Dev& other) {
- Font_Dev copy(other);
- swap(copy);
+ Resource::operator=(other);
return *this;
}
-void Font_Dev::swap(Font_Dev& other) {
- Resource::swap(other);
-}
-
bool Font_Dev::Describe(FontDescription_Dev* description,
PP_FontMetrics_Dev* metrics) const {
if (!font_f)
diff --git a/ppapi/cpp/dev/font_dev.h b/ppapi/cpp/dev/font_dev.h
index 99bfe69..e356b2b 100644
--- a/ppapi/cpp/dev/font_dev.h
+++ b/ppapi/cpp/dev/font_dev.h
@@ -35,7 +35,6 @@ class FontDescription_Dev {
}
FontDescription_Dev& operator=(const FontDescription_Dev& other);
- void swap(FontDescription_Dev& other);
Var face() const { return face_; }
void set_face(const Var& face) {
@@ -81,13 +80,12 @@ class TextRun_Dev {
public:
TextRun_Dev();
TextRun_Dev(const std::string& text,
- bool rtl = false,
- bool override_direction = false);
+ bool rtl = false,
+ bool override_direction = false);
TextRun_Dev(const TextRun_Dev& other);
~TextRun_Dev();
TextRun_Dev& operator=(const TextRun_Dev& other);
- void swap(TextRun_Dev& other);
const PP_TextRun_Dev& pp_text_run() const {
return pp_text_run_;
@@ -111,7 +109,6 @@ class Font_Dev : public Resource {
Font_Dev(const Font_Dev& other);
Font_Dev& operator=(const Font_Dev& other);
- void swap(Font_Dev& other);
// PPB_Font methods:
bool Describe(FontDescription_Dev* description,
diff --git a/ppapi/cpp/dev/scrollbar_dev.cc b/ppapi/cpp/dev/scrollbar_dev.cc
index d24d769..f5dc570 100644
--- a/ppapi/cpp/dev/scrollbar_dev.cc
+++ b/ppapi/cpp/dev/scrollbar_dev.cc
@@ -35,15 +35,10 @@ Scrollbar_Dev::Scrollbar_Dev(const Scrollbar_Dev& other)
}
Scrollbar_Dev& Scrollbar_Dev::operator=(const Scrollbar_Dev& other) {
- Scrollbar_Dev copy(other);
- swap(copy);
+ Resource::operator=(other);
return *this;
}
-void Scrollbar_Dev::swap(Scrollbar_Dev& other) {
- Resource::swap(other);
-}
-
uint32_t Scrollbar_Dev::GetThickness() {
if (!scrollbar_f)
return 0;
diff --git a/ppapi/cpp/dev/scrollbar_dev.h b/ppapi/cpp/dev/scrollbar_dev.h
index 0605641..1890c64 100644
--- a/ppapi/cpp/dev/scrollbar_dev.h
+++ b/ppapi/cpp/dev/scrollbar_dev.h
@@ -23,7 +23,6 @@ class Scrollbar_Dev : public Widget_Dev {
Scrollbar_Dev(const Scrollbar_Dev& other);
Scrollbar_Dev& operator=(const Scrollbar_Dev& other);
- void swap(Scrollbar_Dev& other);
// PPB_Scrollbar methods:
static uint32_t GetThickness();
diff --git a/ppapi/cpp/dev/video_decoder_dev.cc b/ppapi/cpp/dev/video_decoder_dev.cc
index 9868293..bda3b58 100644
--- a/ppapi/cpp/dev/video_decoder_dev.cc
+++ b/ppapi/cpp/dev/video_decoder_dev.cc
@@ -37,15 +37,10 @@ VideoDecoder_Dev::VideoDecoder_Dev(const VideoDecoder_Dev& other)
}
VideoDecoder_Dev& VideoDecoder_Dev::operator=(const VideoDecoder_Dev& other) {
- VideoDecoder_Dev copy(other);
- swap(copy);
+ Resource::operator=(other);
return *this;
}
-void VideoDecoder_Dev::swap(VideoDecoder_Dev& other) {
- Resource::swap(other);
-}
-
// static
bool VideoDecoder_Dev::GetConfig(const Instance& instance,
PP_VideoCodecId_Dev codec,
diff --git a/ppapi/cpp/dev/video_decoder_dev.h b/ppapi/cpp/dev/video_decoder_dev.h
index 0ee6fc96..15743ca 100644
--- a/ppapi/cpp/dev/video_decoder_dev.h
+++ b/ppapi/cpp/dev/video_decoder_dev.h
@@ -26,7 +26,6 @@ class VideoDecoder_Dev : public Resource {
VideoDecoder_Dev(const VideoDecoder_Dev& other);
VideoDecoder_Dev& operator=(const VideoDecoder_Dev& other);
- void swap(VideoDecoder_Dev& other);
// PPB_VideoDecoder methods:
static bool GetConfig(const Instance& instance,
diff --git a/ppapi/cpp/dev/widget_dev.cc b/ppapi/cpp/dev/widget_dev.cc
index 00756e5..46f36b5 100644
--- a/ppapi/cpp/dev/widget_dev.cc
+++ b/ppapi/cpp/dev/widget_dev.cc
@@ -27,15 +27,10 @@ Widget_Dev::Widget_Dev(const Widget_Dev& other) : Resource(other) {
}
Widget_Dev& Widget_Dev::operator=(const Widget_Dev& other) {
- Widget_Dev copy(other);
- swap(copy);
+ Resource::operator=(other);
return *this;
}
-void Widget_Dev::swap(Widget_Dev& other) {
- Resource::swap(other);
-}
-
bool Widget_Dev::Paint(const Rect& rect, ImageData* image) {
if (!widget_f)
return false;
diff --git a/ppapi/cpp/dev/widget_dev.h b/ppapi/cpp/dev/widget_dev.h
index 59ca60d..8252946 100644
--- a/ppapi/cpp/dev/widget_dev.h
+++ b/ppapi/cpp/dev/widget_dev.h
@@ -27,7 +27,6 @@ class Widget_Dev : public Resource {
Widget_Dev(const Widget_Dev& other);
Widget_Dev& operator=(const Widget_Dev& other);
- void swap(Widget_Dev& other);
// PPB_Widget methods:
bool Paint(const Rect& rect, ImageData* image);