Reland "Refactor the locking logic in Resource" (r166704)

This CL makes the logic for locking/unlocking Resources entirely reside in
Resource. This will simplify the use of purgeable memory for derived classes of
Resource. The original CL caused the decoded data of ImageResources to be
destroyed when it still had clients, leading to images disappearing from pages
when switching tabs.

BUG=290193

Review URL: https://codereview.chromium.org/150083004

git-svn-id: svn://svn.chromium.org/blink/trunk@167100 bbb929c8-8fbe-4397-9dbb-9b2b20218538