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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_message_process_host.cc

Issue 815363002: replace COMPILE_ASSERT with static_assert in chrome/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 6 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/api/messaging/native_message_process_host.h" 5 #include "chrome/browser/extensions/api/messaging/native_message_process_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/process/kill.h" 10 #include "base/process/kill.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 DCHECK(task_runner_->BelongsToCurrentThread()); 146 DCHECK(task_runner_->BelongsToCurrentThread());
147 147
148 if (closed_) 148 if (closed_)
149 return; 149 return;
150 150
151 // Allocate new buffer for the message. 151 // Allocate new buffer for the message.
152 scoped_refptr<net::IOBufferWithSize> buffer = 152 scoped_refptr<net::IOBufferWithSize> buffer =
153 new net::IOBufferWithSize(json.size() + kMessageHeaderSize); 153 new net::IOBufferWithSize(json.size() + kMessageHeaderSize);
154 154
155 // Copy size and content of the message to the buffer. 155 // Copy size and content of the message to the buffer.
156 COMPILE_ASSERT(sizeof(uint32) == kMessageHeaderSize, incorrect_header_size); 156 static_assert(sizeof(uint32) == kMessageHeaderSize,
157 "kMessageHeaderSize is incorrect");
157 *reinterpret_cast<uint32*>(buffer->data()) = json.size(); 158 *reinterpret_cast<uint32*>(buffer->data()) = json.size();
158 memcpy(buffer->data() + kMessageHeaderSize, json.data(), json.size()); 159 memcpy(buffer->data() + kMessageHeaderSize, json.data(), json.size());
159 160
160 // Push new message to the write queue. 161 // Push new message to the write queue.
161 write_queue_.push(buffer); 162 write_queue_.push(buffer);
162 163
163 // Send() may be called before the host process is started. In that case the 164 // Send() may be called before the host process is started. In that case the
164 // message will be written when OnHostProcessLaunched() is called. If it's 165 // message will be written when OnHostProcessLaunched() is called. If it's
165 // already started then write the message now. 166 // already started then write the message now.
166 if (write_stream_) 167 if (write_stream_)
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 content::BrowserThread::PostBlockingPoolTask( 357 content::BrowserThread::PostBlockingPoolTask(
357 FROM_HERE, 358 FROM_HERE,
358 base::Bind(&base::EnsureProcessTerminated, Passed(&process_))); 359 base::Bind(&base::EnsureProcessTerminated, Passed(&process_)));
359 #else 360 #else
360 base::EnsureProcessTerminated(process_.Pass()); 361 base::EnsureProcessTerminated(process_.Pass());
361 #endif 362 #endif
362 } 363 }
363 } 364 }
364 365
365 } // namespace extensions 366 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/downloads/downloads_api.cc ('k') | chrome/browser/extensions/api/proxy/proxy_api_constants.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698