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

Side by Side Diff: webkit/blob/deletable_file_reference.cc

Issue 4192012: Convert implicit scoped_refptr constructor calls to explicit ones, part 1 (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: fix presubmit Created 10 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/blob/deletable_file_reference.h" 5 #include "webkit/blob/deletable_file_reference.h"
6 6
7 #include <map> 7 #include <map>
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/file_util_proxy.h" 9 #include "base/file_util_proxy.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 24 matching lines...) Expand all
35 scoped_refptr<DeletableFileReference> DeletableFileReference::GetOrCreate( 35 scoped_refptr<DeletableFileReference> DeletableFileReference::GetOrCreate(
36 const FilePath& path, base::MessageLoopProxy* file_thread) { 36 const FilePath& path, base::MessageLoopProxy* file_thread) {
37 DCHECK(file_thread); 37 DCHECK(file_thread);
38 typedef std::pair<DeleteableFileMap::iterator, bool> InsertResult; 38 typedef std::pair<DeleteableFileMap::iterator, bool> InsertResult;
39 InsertResult result = map()->insert( 39 InsertResult result = map()->insert(
40 DeleteableFileMap::value_type(path, NULL)); 40 DeleteableFileMap::value_type(path, NULL));
41 if (result.second == false) 41 if (result.second == false)
42 return scoped_refptr<DeletableFileReference>(result.first->second); 42 return scoped_refptr<DeletableFileReference>(result.first->second);
43 43
44 // Wasn't in the map, create a new reference and store the pointer. 44 // Wasn't in the map, create a new reference and store the pointer.
45 scoped_refptr<DeletableFileReference> reference = 45 scoped_refptr<DeletableFileReference> reference(
46 new DeletableFileReference(path, file_thread); 46 new DeletableFileReference(path, file_thread));
47 result.first->second = reference.get(); 47 result.first->second = reference.get();
48 return reference; 48 return reference;
49 } 49 }
50 50
51 DeletableFileReference::DeletableFileReference( 51 DeletableFileReference::DeletableFileReference(
52 const FilePath& path, base::MessageLoopProxy* file_thread) 52 const FilePath& path, base::MessageLoopProxy* file_thread)
53 : path_(path), file_thread_(file_thread) { 53 : path_(path), file_thread_(file_thread) {
54 DCHECK(map()->find(path_)->second == NULL); 54 DCHECK(map()->find(path_)->second == NULL);
55 } 55 }
56 56
57 DeletableFileReference::~DeletableFileReference() { 57 DeletableFileReference::~DeletableFileReference() {
58 DCHECK(map()->find(path_)->second == this); 58 DCHECK(map()->find(path_)->second == this);
59 map()->erase(path_); 59 map()->erase(path_);
60 base::FileUtilProxy::Delete(file_thread_, path_, false /* recursive */, NULL); 60 base::FileUtilProxy::Delete(file_thread_, path_, false /* recursive */, NULL);
61 } 61 }
62 62
63 } // namespace webkit_blob 63 } // namespace webkit_blob
OLDNEW
« no previous file with comments | « webkit/blob/blob_url_request_job_unittest.cc ('k') | webkit/fileapi/file_system_path_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698