Remove a scoped_refptr<>::swap overload

A scoped_refptr<>::swap overload is used to insert or remove the internal
pointer without manipulating the ref count. That functionality should not
be exposed, or at least, should be exposed separately with better name.

This CL removes the swap() overload, and rewrites callers without swap().

Review-Url: https://codereview.chromium.org/2723083004
Cr-Commit-Position: refs/heads/master@{#455407}


CrOS-Libchrome-Original-Commit: 511c810d540422faf221bd82a4532313cabcc4c4
diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h
index ff46e6d..9c9aea1 100644
--- a/base/memory/ref_counted.h
+++ b/base/memory/ref_counted.h
@@ -7,6 +7,7 @@
 
 #include <stddef.h>
 
+#include <algorithm>
 #include <cassert>
 #include <iosfwd>
 #include <type_traits>
@@ -354,15 +355,7 @@
     return *this;
   }
 
-  void swap(T** pp) {
-    T* p = ptr_;
-    ptr_ = *pp;
-    *pp = p;
-  }
-
-  void swap(scoped_refptr<T>& r) {
-    swap(&r.ptr_);
-  }
+  void swap(scoped_refptr<T>& r) { std::swap(ptr_, r.ptr_); }
 
   explicit operator bool() const { return ptr_ != nullptr; }