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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/operations/write_file.cc

Issue 2392693002: Rewrite simple uses of base::ListValue::Append(base::Value*) on CrOS. (Closed)
Patch Set: MakeUnique Created 4 years, 2 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/chromeos/file_system_provider/operations/write_file.h" 5 #include "chrome/browser/chromeos/file_system_provider/operations/write_file.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // Length is not passed directly since it can be accessed via data.byteLength. 47 // Length is not passed directly since it can be accessed via data.byteLength.
48 48
49 // Set the data directly on base::Value() to avoid an extra string copy. 49 // Set the data directly on base::Value() to avoid an extra string copy.
50 DCHECK(buffer_.get()); 50 DCHECK(buffer_.get());
51 std::unique_ptr<base::DictionaryValue> options_as_value = options.ToValue(); 51 std::unique_ptr<base::DictionaryValue> options_as_value = options.ToValue();
52 options_as_value->Set( 52 options_as_value->Set(
53 "data", 53 "data",
54 base::BinaryValue::CreateWithCopiedBuffer(buffer_->data(), length_)); 54 base::BinaryValue::CreateWithCopiedBuffer(buffer_->data(), length_));
55 55
56 std::unique_ptr<base::ListValue> event_args(new base::ListValue); 56 std::unique_ptr<base::ListValue> event_args(new base::ListValue);
57 event_args->Append(options_as_value.release()); 57 event_args->Append(std::move(options_as_value));
58 58
59 return SendEvent( 59 return SendEvent(
60 request_id, 60 request_id,
61 extensions::events::FILE_SYSTEM_PROVIDER_ON_WRITE_FILE_REQUESTED, 61 extensions::events::FILE_SYSTEM_PROVIDER_ON_WRITE_FILE_REQUESTED,
62 extensions::api::file_system_provider::OnWriteFileRequested::kEventName, 62 extensions::api::file_system_provider::OnWriteFileRequested::kEventName,
63 std::move(event_args)); 63 std::move(event_args));
64 } 64 }
65 65
66 void WriteFile::OnSuccess(int /* request_id */, 66 void WriteFile::OnSuccess(int /* request_id */,
67 std::unique_ptr<RequestValue> /* result */, 67 std::unique_ptr<RequestValue> /* result */,
68 bool /* has_more */) { 68 bool /* has_more */) {
69 TRACE_EVENT0("file_system_provider", "WriteFile::OnSuccess"); 69 TRACE_EVENT0("file_system_provider", "WriteFile::OnSuccess");
70 callback_.Run(base::File::FILE_OK); 70 callback_.Run(base::File::FILE_OK);
71 } 71 }
72 72
73 void WriteFile::OnError(int /* request_id */, 73 void WriteFile::OnError(int /* request_id */,
74 std::unique_ptr<RequestValue> /* result */, 74 std::unique_ptr<RequestValue> /* result */,
75 base::File::Error error) { 75 base::File::Error error) {
76 TRACE_EVENT0("file_system_provider", "WriteFile::OnError"); 76 TRACE_EVENT0("file_system_provider", "WriteFile::OnError");
77 callback_.Run(error); 77 callback_.Run(error);
78 } 78 }
79 79
80 } // namespace operations 80 } // namespace operations
81 } // namespace file_system_provider 81 } // namespace file_system_provider
82 } // namespace chromeos 82 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/file_manager/url_util.cc ('k') | chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698