Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Allow use of metrics protobuf from java.
Browse files Browse the repository at this point in the history
The protobuf compiler cannot currently generate the java classes needed
for reading and writing metrics messages. The java generator uses the
filename of the .proto to create an outer class which contains the
message as an inner class. Since nearly all of the metrics proto
messages have the same message name as filename protoc fails with this
error:

--javanano_out: chrome_user_metrics_extension.proto:
chrome_user_metrics_extension.proto: Cannot generate Java output because
the file's outer class name, "ChromeUserMetricsExtension", matches the
name of one of the types declared inside it.  Please either rename the
type or use the java_outer_classname option to specify a different outer
class name for the .proto file.

By manually specifying the outer classname the generator succeeds. Due
to some inconsistent naming of the messages (some have Proto at the end
of the message, others do not) we append "Protos" to each of the outer
class names. This makes their purpose clear and gives some consistency
when referring to them.

BUG=478977

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

Cr-Commit-Position: refs/heads/master@{#325964}
  • Loading branch information
davileen authored and Commit bot committed Apr 21, 2015
1 parent aa05873 commit 4c35716
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions components/metrics/proto/call_stack_profile.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
syntax = "proto2";

option optimize_for = LITE_RUNTIME;
option java_outer_classname = "CallStackProfileProtos";
option java_package = "org.chromium.components.metrics";

package metrics;

Expand Down
2 changes: 2 additions & 0 deletions components/metrics/proto/cast_logs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
syntax = "proto2";

option optimize_for = LITE_RUNTIME;
option java_outer_classname = "CastLogsProtos";
option java_package = "org.chromium.components.metrics";

package metrics;

Expand Down
2 changes: 2 additions & 0 deletions components/metrics/proto/chrome_user_metrics_extension.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
syntax = "proto2";

option optimize_for = LITE_RUNTIME;
option java_outer_classname = "ChromeUserMetricsExtensionProtos";
option java_package = "org.chromium.components.metrics";

package metrics;

Expand Down
2 changes: 2 additions & 0 deletions components/metrics/proto/histogram_event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
syntax = "proto2";

option optimize_for = LITE_RUNTIME;
option java_outer_classname = "HistogramEventProtos";
option java_package = "org.chromium.components.metrics";

package metrics;

Expand Down
2 changes: 2 additions & 0 deletions components/metrics/proto/omnibox_event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
syntax = "proto2";

option optimize_for = LITE_RUNTIME;
option java_outer_classname = "OmniboxEventProtos";
option java_package = "org.chromium.components.metrics";

package metrics;

Expand Down
2 changes: 2 additions & 0 deletions components/metrics/proto/omnibox_input_type.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
syntax = "proto2";

option optimize_for = LITE_RUNTIME;
option java_outer_classname = "OmniboxInputTypeProtos";
option java_package = "org.chromium.components.metrics";

package metrics.OmniboxInputType;

Expand Down
2 changes: 2 additions & 0 deletions components/metrics/proto/perf_data.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
syntax = "proto2";

option optimize_for = LITE_RUNTIME;
option java_outer_classname = "PerfDataProtos";
option java_package = "org.chromium.components.metrics";

package metrics;

Expand Down
4 changes: 3 additions & 1 deletion components/metrics/proto/profiler_event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
syntax = "proto2";

option optimize_for = LITE_RUNTIME;
option java_outer_classname = "ProfilerEventProtos";
option java_package = "org.chromium.components.metrics";

package metrics;

Expand Down Expand Up @@ -121,4 +123,4 @@ message ProfilerEventProto {
optional uint32 process_id = 12;
}
repeated TrackedObject tracked_object = 3;
}
}
2 changes: 2 additions & 0 deletions components/metrics/proto/sampled_profile.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
syntax = "proto2";

option optimize_for = LITE_RUNTIME;
option java_outer_classname = "SampledProfileProtos";
option java_package = "org.chromium.components.metrics";

package metrics;

Expand Down
2 changes: 2 additions & 0 deletions components/metrics/proto/system_profile.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
syntax = "proto2";

option optimize_for = LITE_RUNTIME;
option java_outer_classname = "SystemProfileProtos";
option java_package = "org.chromium.components.metrics";

package metrics;

Expand Down
2 changes: 2 additions & 0 deletions components/metrics/proto/user_action_event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
syntax = "proto2";

option optimize_for = LITE_RUNTIME;
option java_outer_classname = "UserActionEventProtos";
option java_package = "org.chromium.components.metrics";

package metrics;

Expand Down

0 comments on commit 4c35716

Please sign in to comment.