Commit 00e2bd6b authored by kulshin's avatar kulshin Committed by Commit bot

Make File::Duplicate const

BUG=

Review-Url: https://codereview.chromium.org/2163063002
Cr-Commit-Position: refs/heads/master@{#406665}
parent eeb3a0e2
......@@ -290,7 +290,7 @@ class BASE_EXPORT File {
// object that was created or initialized with this flag will have unlinked
// the underlying file when it was created or opened. On Windows, the
// underlying file is deleted when the last handle to it is closed.
File Duplicate();
File Duplicate() const;
bool async() const { return async_; }
......
......@@ -370,7 +370,7 @@ File::Error File::Unlock() {
return CallFcntlFlock(file_.get(), false);
}
File File::Duplicate() {
File File::Duplicate() const {
if (!IsValid())
return File();
......
......@@ -55,7 +55,7 @@ FileTracing::ScopedTrace::~ScopedTrace() {
}
void FileTracing::ScopedTrace::Initialize(const char* name,
File* file,
const File* file,
int64_t size) {
id_ = &file->trace_enabler_;
name_ = name;
......
......@@ -37,21 +37,21 @@ class BASE_EXPORT FileTracing {
virtual bool FileTracingCategoryIsEnabled() const = 0;
// Enables file tracing for |id|. Must be called before recording events.
virtual void FileTracingEnable(void* id) = 0;
virtual void FileTracingEnable(const void* id) = 0;
// Disables file tracing for |id|.
virtual void FileTracingDisable(void* id) = 0;
virtual void FileTracingDisable(const void* id) = 0;
// Begins an event for |id| with |name|. |path| tells where in the directory
// structure the event is happening (and may be blank). |size| is the number
// of bytes involved in the event.
virtual void FileTracingEventBegin(const char* name,
void* id,
const void* id,
const FilePath& path,
int64_t size) = 0;
// Ends an event for |id| with |name|.
virtual void FileTracingEventEnd(const char* name, void* id) = 0;
virtual void FileTracingEventEnd(const char* name, const void* id) = 0;
};
// Sets a global file tracing provider to query categories and record events.
......@@ -73,12 +73,12 @@ class BASE_EXPORT FileTracing {
// event to trace (e.g. "Read", "Write") and must have an application
// lifetime (e.g. static or literal). |file| is the file being traced; must
// outlive this class. |size| is the size (in bytes) of this event.
void Initialize(const char* name, File* file, int64_t size);
void Initialize(const char* name, const File* file, int64_t size);
private:
// The ID of this trace. Based on the |file| passed to |Initialize()|. Must
// outlive this class.
void* id_;
const void* id_;
// The name of the event to trace (e.g. "Read", "Write"). Prefixed with
// "File".
......
......@@ -249,7 +249,7 @@ File::Error File::Unlock() {
return FILE_OK;
}
File File::Duplicate() {
File File::Duplicate() const {
if (!IsValid())
return File();
......
......@@ -20,23 +20,26 @@ bool FileTracingProviderImpl::FileTracingCategoryIsEnabled() const {
return enabled;
}
void FileTracingProviderImpl::FileTracingEnable(void* id) {
void FileTracingProviderImpl::FileTracingEnable(const void* id) {
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(
kFileTracingEventCategoryGroup, FILE_TRACING_PREFIX, id);
}
void FileTracingProviderImpl::FileTracingDisable(void* id) {
void FileTracingProviderImpl::FileTracingDisable(const void* id) {
TRACE_EVENT_NESTABLE_ASYNC_END0(
kFileTracingEventCategoryGroup, FILE_TRACING_PREFIX, id);
}
void FileTracingProviderImpl::FileTracingEventBegin(
const char* name, void* id, const base::FilePath& path, int64_t size) {
void FileTracingProviderImpl::FileTracingEventBegin(const char* name,
const void* id,
const base::FilePath& path,
int64_t size) {
TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(kFileTracingEventCategoryGroup, name, id,
"path", path.AsUTF8Unsafe(), "size", size);
}
void FileTracingProviderImpl::FileTracingEventEnd(const char* name, void* id) {
void FileTracingProviderImpl::FileTracingEventEnd(const char* name,
const void* id) {
TRACE_EVENT_NESTABLE_ASYNC_END0(kFileTracingEventCategoryGroup, name, id);
}
......
......@@ -21,11 +21,13 @@ class FileTracingProviderImpl : public base::FileTracing::Provider {
// base::FileTracing::Provider:
bool FileTracingCategoryIsEnabled() const override;
void FileTracingEnable(void* id) override;
void FileTracingDisable(void* id) override;
void FileTracingEventBegin(const char* name, void* id,
const base::FilePath& path, int64_t size) override;
void FileTracingEventEnd(const char* name, void* id) override;
void FileTracingEnable(const void* id) override;
void FileTracingDisable(const void* id) override;
void FileTracingEventBegin(const char* name,
const void* id,
const base::FilePath& path,
int64_t size) override;
void FileTracingEventEnd(const char* name, const void* id) override;
private:
DISALLOW_COPY_AND_ASSIGN(FileTracingProviderImpl);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment